How do you stop the form from being submitted if a javascript error, which
was called from the <html:form onsubmit...>,  occurs. I get an error and I
say ok and the javascript tries to put focus on the field which is causing
the error, but the form still submits to the action class.

Here is some code:
<script>
 function validate()
{
        if (document.forms[0].username.value == "")
        {
                alert("User Name is a required field. Please fill in your User Name.");
                document.forms[0].focus();
                document.forms[0].select();
                return false;
        }
        return true;
}
</script>

<html:form action="jsp/change_password.do" focus="username" onsubmit="return
validate();">
....


Thanks for your time.

Thinh

Reply via email to