ayok Posted March 25, 2009 Share Posted March 25, 2009 Hi, I have a question regarding my form validation with javascript, which is working on IE, or even on Google chrome, but doesn't work on Firefox. The script is like below: <script type="text/javascript"> <!-- function validateClientForm() { if(document.clientInfo.name.value == ''){ alert('your name please'); clientInfo.name.focus(); return false; } else if(document.clientInfo.adres.value == ''){ alert('your address please'); clientInfo.adres.focus(); return false; } } // --> </script> <form name="clientInfo" method="post" action="send.php" onsubmit="return validateClientForm();"> <input type="text" name="name"/> <input type="text" name="adres"/> <input type="submit" value="send"/> </form> So in other browsers besides firefox, the warning appears if i don't fill in the name and address fields. And when i click ok, it stays on the same page. However in firefox, when i click ok after the alert box appears, it goes to the next page. Could anyone tell me what's wrong with the codes or firefox? Thanks, ayok Link to comment https://forums.phpfreaks.com/topic/151112-alert-box-form-validation-doesnt-work-in-firefox/ Share on other sites More sharing options...
darkfreaks Posted March 25, 2009 Share Posted March 25, 2009 try using === instead of ==: function validateClientForm() { if(document.clientInfo.name.value === ''){ alert('your name please'); clientInfo.name.focus(); return false; } else if(document.clientInfo.adres.value === ''){ alert('your address please'); clientInfo.adres.focus(); return false; } } Link to comment https://forums.phpfreaks.com/topic/151112-alert-box-form-validation-doesnt-work-in-firefox/#findComment-793843 Share on other sites More sharing options...
ayok Posted March 25, 2009 Author Share Posted March 25, 2009 Hi, thanks. But it still doesn't work. Link to comment https://forums.phpfreaks.com/topic/151112-alert-box-form-validation-doesnt-work-in-firefox/#findComment-793875 Share on other sites More sharing options...
darkfreaks Posted March 25, 2009 Share Posted March 25, 2009 do you have a demo or link i could look at ??? Link to comment https://forums.phpfreaks.com/topic/151112-alert-box-form-validation-doesnt-work-in-firefox/#findComment-793883 Share on other sites More sharing options...
ayok Posted March 25, 2009 Author Share Posted March 25, 2009 Oh.. I tried the codes i wrote on my first post online, and it works. But the real script i have is much longer. I probably made mistake. I'm going to see first what's wrong. I'll get back if it still doesn't work. Thank you for your replies. ayok Link to comment https://forums.phpfreaks.com/topic/151112-alert-box-form-validation-doesnt-work-in-firefox/#findComment-793922 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.