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

can't stop submit 1

Status
Not open for further replies.

TruthInSatire

Programmer
Aug 12, 2002
2,964
US
i have a field validation script in and onsubmit function. I return false and it still submits the form please help.

<script language = &quot;javascript&quot;>
function chkOptions(){
rtn = true;
if (sOptions.sOver.checked && shipOptions.sOverAmount.value == ''){
alert('Over Amount Required');
sOptions.sOverAmount.focus();
rtn = false;
}
return rtn;
}
</script>
How many software developers does it take to change a light bulb?
None: it works in everyone else’s office, it must work in yours too.
 

post the rest of the code, at least the form part.

- g
 
<form name = &quot;sOptions&quot; method = &quot;post&quot; onsubmit = &quot;chkOptions();&quot;>
<input type = &quot;checkbox&quot; name = &quot;sUseOver&quot; value = &quot;Yes&quot;>
Over Amount:
<input type = &quot;text&quot; size = &quot;6&quot; name = &quot;sOverAmount&quot;>
<input type=&quot;image&quot; value=&quot;submit&quot; border=&quot;0&quot; src=&quot;save.jpg&quot; width=&quot;126&quot; height=&quot;24&quot;>
</form>

How many software developers does it take to change a light bulb?
None: it works in everyone else’s office, it must work in yours too.
 

how about...

***
<script language = &quot;javascript&quot;>
function chkOptions(){
rtn = true;
if ((sOptions.sUseOver.checked)&&(sOptions.sOverAmount.value=='')) {
alert('Over Amount Required');
sOptions.sOverAmount.focus();
rtn = false;

}
return rtn;
}
</script>

<form name=&quot;sOptions&quot; method=post onsubmit=&quot;return chkOptions();&quot; action=javascript:alert('submitted!!');>
<input type = &quot;checkbox&quot; name = &quot;sUseOver&quot; value=&quot;Yes&quot;>
Over Amount:
<input type = &quot;text&quot; size = &quot;6&quot; name = &quot;sOverAmount&quot;>
<input type=&quot;image&quot; value=&quot;submit&quot; border=&quot;0&quot; src=&quot;save.jpg&quot; width=&quot;126&quot; height=&quot;24&quot;>
</form>
***

hope that helps...

-g

 
When I use this as the function:


function chkOptions(){
alert(&quot;chkOptions&quot;);
return false;
}


It works fine. So your logic in your function is bad.

-pete
 
function chkOptions(){
var rtn = true;
...
Never too old to learn...
Nico
 
spewn wins. thank you. How many software developers does it take to change a light bulb?
None: it works in everyone else’s office, it must work in yours too.
 
I've written an FAQ for this, hope it meets with everybody's approval. [bigsmile] Hope I helped / Thanks for helping
if ((x<10&&y<10) &&(((parseInt(x.toString()+y.toString())-x-y)%9)!=0)){ alert(&quot;I'm a monkey's uncle&quot;); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top