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

cancel a form action 1

Status
Not open for further replies.

tyris

Programmer
Nov 2, 2000
311
FR
hi all;
i do have a button in a form.
what i want is to do something like :

if (document.myForm.searchDone.value != "ok") {
alert("You may not have selected a currency");
STOP THE FORM SUBMIT ACTION
}

i thought i could do this :
<INPUT name=apply type=submit value=Update onclick=&quot;(here is my test and here i stop the action)&quot;>

what could i do ?

i have tryed

<INPUT name=apply type=submit value=Update onclick=&quot;if (document.myForm.searchDone.value != &quot;ok&quot;) ? alert(&quot;You may not have selected a currency&quot;); return false;&quot;>

but i do have to error :&quot;syntax error&quot;

where is the problem ?



Best regards X-),
Elise
 
try:

<script>
function validate(){
if (document.myForm.searchDone.value != &quot;ok&quot;) {
alert(&quot;You may not have selected a currency&quot;);
return false}
return true
}
</script>

<form onsubmit=&quot;return validate()&quot;>

This will stop the form from submitting if validate returns false. jared@eae.net -
 
great that works ! thank you ! :eek:) Best regards X-),
Elise
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top