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!

Check 2 javascript function before submitting the form 2

Status
Not open for further replies.

sunila7

Technical User
Joined
Apr 11, 2001
Messages
1,087
Location
US
Hi,

I want to check 2 boolean function's value before submitting the form
This is how the code looks like now
<form action=&quot;Enrollment/ChooseBenefit.asp?<%=strPass%>&quot; name=&quot;BenefitForm&quot; method=&quot;Post&quot; onSubmit=&quot;return chkValue();&quot; >
Now I want to add another boolean function to onSubmit event
so that only if both of them are true the form should be submitted.

Thanks for any help

Sunil

Sunil
 
create a function that returns true when both checks are passed, false when one (or both) fails. Stop the processing when failed with window.event.returnValue = false;
Enter the function name in the onSubmit and chkValue() inside the new function.
Code:
function check_this(){
 if (chkValue() && chkValue2()) return true ;
 else window.event.returnValue = false ;
}
or something like that.


Erwin Oosterhoorn
Analyst Programmer,
Roller hockey'er, biker,
ice hockey player/fan.
 
Why not write a new function that is called on submit that checks the 2 functions you need, then returns true or false?

function validate() {
if(chkValue() && someotherfunction())
return true;
else
return false;
}

<form action=&quot;Enrollment/ChooseBenefit.asp?<%=strPass%>&quot; name=&quot;BenefitForm&quot; method=&quot;Post&quot; onSubmit=&quot;return validate();&quot; >
 

Thanks guys.... just what I needed.......

Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top