java script is not working in mozila

Posted by Piyush on Stack Overflow See other posts from Stack Overflow or by Piyush
Published on 2010-05-16T19:49:14Z Indexed on 2010/05/16 20:00 UTC
Read the original article Hit count: 180

Filed under:

I have added some javascript in html page for input validation.same page is working correct in IE and chrome but in mozila its not working.The problem is when user inputs invalid data its supposed to show alert msg box and when user clicks OK it should return false to form...BUT mozila is not waiting for alert box it just shows alert box for 5-6 sec and then goes to next page defined in form action="nextpage.php"

 function validate_form(thisform) 
    {
    with (thisform) 
        {
        if (validate_required(oldpassword, "<b>Error: </b>Please enter the Old Password!") == false)
        { changeColor("oldpassword"); return false; }

        else if (valid_length(newpassword, "<b>Error: </b>Please enter the New Password!!") == false)
        {newpassword.value=""; changeColor("newpassword"); return false; }

        else if (valid_length(cnfpassword, "<b>Error: </b>Please enter the Confirm Password!!") == false)
        {cnfpassword.value=""; changeColor("cnfpassword"); return false; }

        else if (document.getElementById('newpassword').value != document.getElementById('cnfpassword').value)
        {changeColor("newpassword");cool.error("<b>Error: </b>Passwords entered are not same!"); 
        newpassword.value="";cnfpassword.value="";return false;}

    }
}function validate_required(field, alerttxt) 
    {
    with (field) 
        {
        if (value == null || value == "") 
            {
           cool.error(alerttxt);return false;
            }
        else 
            {
            return true;
            }
        }
    }

cool.error is nothing but CSS nd Js for alert box.I thing there is not any problem in my code weather problem is in some browser settings.Is it so??? because it is working fine in IE and Chrome.

© Stack Overflow or respective owner

Related posts about JavaScript