Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No submit when password not same?

Status
Not open for further replies.
May 9, 2000
446
GB
Hi, i've got a validation script that checks that two passwords are the same when entered on a change password asp. Anyway when they click on the submit button the msgbox appears saying "The passwords don't match" etc but then the form submits anyway! How do I stop the form from submitting if the passwords aren't the same?

Cheers
Gary
 
You need to specify a function in the OnSubmit event for the form that returns either true or false. If it returns false the form does not submit (but you must have the "return" keyword in the call to the function). Here is some example code for a web page that does what I am talking about:

<HTML>

<SCRIPT LANGUAGE=Javascript>

function ReturnFalse()
{
alert(&quot;Tried to submit!&quot;);
return false;
}

</SCRIPT>

<BODY>
<FORM ACTION=&quot;SomePage.htm&quot; METHOD=POST OnSubmit='javascript: return ReturnFalse();'>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>

</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top