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 Quote Link to comment 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; } } Quote Link to comment 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. Quote Link to comment 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 ??? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.