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!

OnSubmit Problems...

Status
Not open for further replies.

Fredde

Programmer
May 10, 2001
22
SE
I want to prevent the action when a value in "sumtot" is "NaN". According to what I understand returning false from an onSubmit function should cancel the FORM action?!
code:

HTML:
<FORM name=&quot;fm&quot; onSubmit=&quot;return CheckValues()&quot; method=get action=&quot;Save.asp&quot;>

SCRIPT:
function CheckValues() {
if (isNaN(document.fm.sumtot.value) == true) {
alert(&quot;Illegal value&quot;);
return false;
}
}

/Fredrik
 
Yes, but you got a little redundant. No need to ask if it's ==true -- you can just evaluate isNaN. Try this, and see if it works:

<FORM name=&quot;fm&quot; onSubmit=&quot;return CheckValues();&quot; method=get action=&quot;Save.asp&quot;>

function CheckValues() {
if (isNaN(document.fm.sumtot.value)) {
alert(&quot;Illegal value&quot;);
return false;
}
return true;
}

:)
Paul Prewett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top