Need help with an onsubmit return script that will check 2 functions
I am trying to prevent submission of a form if either or both of 2 functions return false. I've tried calling the functions in my form this way:
<form action="tuition-calculator.php" name="orderform" id="tuition-schedule" method="post" onsubmit="return (tuesThurs() && setTuition())">, but it doesn't stop the submission, even if the results are false.
So...now I've tried this:
(in header)
<script type="text/javascript">
function formValidation(myForm)
{
var result = tuesThurs(myForm);
var result2 = setTuition(myForm);
results = result && result2;
return results;
}
</script>
If the values are "false" for both functions, the proper alerts appear and the submission doesn't happen. If I change my entries so that tuesThurs returns a "true" but setTuition returns a false, the alert for setTuition appears, but the submission goes through anyway. I do not want it to be submitted until both functions are true.
Are you sure you're returning the correct values from both tuesThurs and setTuition? And there are no errors? Because both of the above methods are correct and should work.
Bookmarks