javascript - java script is not working in mozila -


I've added some JavaScript to the html page for input validation. The page is working correctly in IE and Chrome but it does not work. The problem is that when the user gets invalid data showing the warning message box and when the user clicks on OK then it should return false But is not waiting for the Mozilla warning box , it only shows a warning box for 5-6 seconds and then

validate_form (thisform) {with (thisform) {if (validate_required (oldpassword, "& lt; b & gt; error: & lt; / b & gt; ; Please enter old password! ") == incorrect) {changeColor (" oldpassword "); return false; } And if (valid_language (newpassword, "<<"> please enter new password !!) == incorrect) {newpassword.value = ""; ChangeColor ("newpassword"); return false; } And if (valid_language (cnf password, "& lt; b & gt; error: & lt; / b & gt; please confirm password" !!) == incorrect) {cnfpassword.value = ""; ChangeColor ("cnfpassword"); return false; } Else if (document.getElementById ('newpassword'). Value! = Document.getElementById ('cnfpassword') value) {changeColor ("newpassword"); Cool.error ("& lt; b & gt; error: & lt; / b & gt; passwords entered are not the same!"); Newpassword.value = ""; Cnfpassword.value = ""; Return false;}}} function validate_required (area, alerttxt) {(with field) {if (value == null = value == "") {cool. Error (alerttxt); Return false; } And {return true; }}}

cool.error CSS for the alert box is nothing nd JS and nothing else. My point is that there is no problem in my code weather problem is in some browser settings. is that so ??? Because it's working fine in IE and Chrome .

You are using a non-standard IE-only behavior for each element with the ID Creates global variables

To fix this, add a global variable for each element that you use:

  var oldpassword = document.getElementById ("old password") ;  

In addition, you should not use the ever javascript with the block .
It is very different from VB's block, and it should not be used unless you actually understand its losses and drawbacks. This will also slow down your code.


Comments