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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop Submit

Status
Not open for further replies.
May 9, 2000
446
GB
Hi i've got a password change page where, no suprise users can change their passwords. Anyway if the two new passwords entered aren't the same when the submit button is clicked an alert box is shown but the page is still submitted and the password changes, how can I stop the submit if the values for the new password are different?

Cheers

Gary
 
see if you write

<input type=submit name=sub value=Submit onClick=return FunctionName()>

Or if you use

<input type=button name=sub value=Submit onClick=FunctionName() >

Just see type id different

Now in case I
Code:
function FunctionName()
{
if(..condition check..)
  {
  //Incase passwords diffrent
  alert(both pwds shld not be same);
  return false;
  }
else
  {
  //in case pwds same
  return true
  }
}
so form will be submitted according to action specified.

in case II
Code:
function FunctionName()
{
if(..condition check..)
  {
  //Incase passwords diffrent
  alert(both pwds shld not be same);
  document.FormName.method=post;  
  document.FormName.action=&quot;wantedPage.asp&quot;;
  document.FormName.submit();  
    }
}

No need of else Right !!
Now just remember that Return with type submit that is cricial.

Now this deserves a star right !(Joking !!)
Rushi Shroff Rushi@emqube.com
&quot;Life is beautiful.&quot;
 
sorry for the alert message
alert(both pwds shld be same);
Rushi Shroff Rushi@emqube.com
&quot;Life is beautiful.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top