Reputation: 5619
I have the following form:
<form onsubmit="return testform(tolowanswers,emptyAnswers);" class="edit_question" id="edit_question"
I check the Form before submit with the function testform, Is there a possibility to run a second function after testform()
thanks
Upvotes: 0
Views: 806
Reputation: 18566
You just have to put those two functions inside the onsubmit event itself like below
"return (testform(tolowanswers,emptyAnswers) && secondFn())"
It will check if the first function is true and only if it returns true, then the secondFn will be executed.
Another way would be to invoke secondFn()
inside testForm
function after all validation.
Upvotes: 1
Reputation: 388316
One easy solution could to call the function like
return testform(tolowanswers,emptyAnswers) && secondmethod();
this will call the second function if testform
returns true.
Another solution could to use another function like
onsubmit="return myfunction();"
then
function myfunction() {
if (testfunction()) {
secondfunction();
} else {
return false;
}
}
Upvotes: 1