Reputation: 293
I have a function that triggers a number of other functions:
function formvalidation()
{
ZeroSite();
BlankPC();
BlankSite();
BlankSeats();
}// End of formvalidation
and a form like so:
<form id="quote" name="quote" method="get" onSubmit='return formvalidation();' action="testing.php">
The problem being, if one of the individule functions returns flase then the form still gets submitted, is there any way of passing the return false to the parent function?
Thanks for looking, B.
Upvotes: 1
Views: 2344
Reputation: 5710
I see 3 people have already been kind enough to give you identical and perfectly good answers :-) However, using bitwise ANDs instead, you can make sure all the functions are called, even though a previous one has returned false.
function formvalidation() {
return Boolean( ZeroSite() & BlankPC() & BlankSite() & BlankSeats() );
}
Upvotes: 1
Reputation: 3052
When all of these functions just return a value you must check for that value...
function formvalidation()
{
return (ZeroSite() && BlankPC() && BlankSite() && BlankSeats());
}// End of formvalidation
Upvotes: 0
Reputation: 166071
Try something like:
function formvalidation() {
return(ZeroSite() && BlankPC() && BlankSite() && BlankSeats());
}
If any of your other functions return false, the return statement will evaluate to false and the main function will also return false.
Upvotes: 0
Reputation: 2704
Check if all the functions return true, if not return false. Example below
function formvalidation() {
return (ZeroSite() && BlankPC() && BlankSite() && BlankSeats());
}
Upvotes: 2