Hi,
I have developed a web application in asp.net, i ahve used javascript code for validation, it is working fine in Internet Explorer but it is not working on Mozilla browser.
Any help would be appreciated.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Suthish NairRank #92 · 22.8K reputationPosted Mar 1, 2011, 6:59 AM EST
Manikavelu VelayuthamRank #413 · 6K reputationPosted Feb 21, 2011, 11:03 PM EST
If your application will be executed in different browser means, you should use Jquery for client side validation. Thats the only Javascript Validation solution, or else you need to write a seperate code for each browser. Jquery is compatible in all the browsers.
sumeet vaity2 reputationPosted Feb 28, 2011, 7:59 PM EST
you can use simple javascript code with proper function or else check your css file because most case browser error is get prompted by css file on that text box.
thanks and regards,
Vijay YadavRank #1,637 · 943 reputationPosted Feb 28, 2011, 9:15 PM EST
I have javascript code for validation but it is compatible with IE only not with Mozilla, Google chrome n all.
Any idea regarding that, please help!
Suthish NairRank #92 · 22.8K reputationPosted Feb 28, 2011, 10:06 PM EST
Vijay YadavRank #1,637 · 943 reputationPosted Feb 28, 2011, 11:53 PM EST
Here is the javascript code that i am using for validation:-
// Phone Validation
function Validate()
{
if (!((event.keyCode >= 48 && event.keyCode <= 57) || event.keyCode == 8 || event.keyCode == 47 || event.keyCode == 45 || event.keyCode == 43))
event.returnValue=false;
}
It works fine in IE but not in Mozilla and Google Chrome.
Any Idea? Please help.
Manikavelu VelayuthamRank #413 · 6K reputationPosted Mar 1, 2011, 12:47 AM EST
You can see the below link, which explains the Javascript different behavior in Cross Browser.
In IE --> keyCode will work, but in Mozillo, it wont.
For Mozilla You need to use as charCode.
http://www.javascriptkit.com/javatutors/javascriptkey2.shtml
Refer this link too to have a clear idea
http://forums.devshed.com/javascript-development-115/event-keycode-problem-in-mozilla-274765.html
http://bytes.com/topic/javascript/answers/648090-event-keycode-9-tab-event-doesnt-work-firefox
Manikavelu VelayuthamRank #413 · 6K reputationPosted Mar 1, 2011, 12:48 AM EST
Vijay YadavRank #1,637 · 943 reputationPosted Mar 1, 2011, 1:40 AM EST
Manikavelu VelayuthamRank #413 · 6K reputationPosted Mar 1, 2011, 1:46 AM EST
http://stackoverflow.com/questions/995183/how-to-allow-only-numeric-0-9-in-html-inputbox-using-jquery
http://stackoverflow.com/questions/302122/jquery-event-keypress-which-key-was-pressed
http://stackoverflow.com/questions/2812585/jquery-validate-characters-on-keypress
You could also look into www.JQuery.com to see how to use jquery in your code.
Vijay YadavRank #1,637 · 943 reputationPosted Mar 1, 2011, 7:03 PM EST
Thanks for reply its working!!!