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!

how to stop submit 1

Status
Not open for further replies.

hmcheung

Programmer
Oct 13, 2000
66
HK
I've got a code like this:


<script language=&quot;javascript&quot;>

function check(){
if (criteria){
alert ('Please make a valid selection.')}

}

</script>

<form action=mypage.asp onsubmit=check()>
....................
</form>




Now if the criteria is fulfilled, the alert box comes out. After the user press on the button on the alert box, the form will continue to submit. How can I keep stop the form from submitting and bring the user back to select again? Thanks! [sig][/sig]
 
Try this in your function:-

function check(){
if (criteria){
alert ('Please make a valid selection.');

return false;

}
}

[sig][/sig]
 
In addition to what fatbloke posted, you also have to change your form tag to accept the return value:

<form action='mypage.asp' onsubmit='return check()'>
[sig]<p>nick bulka<br><a href=mailto: > </a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top