|
|
Q1302 Is it possible to have one "submit" button activate two "onSubmits" in order for a form to be validated?
irt.org | Knowledge Base | JavaScript | Form | Q1302 [ previous next ] Q1302 Is it possible to have one "submit" button activate two "onSubmits" in order for a form to be validated?There is only one onSubmit event handler per form. But it can do more than one thing:
If you want the onSubmit event handler to invoke a funtion to validate form data, then ensure that the function returns true (valid data) or false (invalid data) and then return the result in the onSubmit handler:
To invoke two funtions and combine the results ue:
When you hit a submit button the onSubmit event handler invoked. You can also submit a form using JavaScript, e.g.:
However, the onSubmit event handler will NOT not invoked, but you can always invoke it yourself:
Likewise, you could invoke two functions to validate your form:
Note, that in the last example, if function1() returns false function2() will not be invoked. To add this to your own "submit" button use:
Feedback on 'Q1302 Is it possible to have one "submit" button activate two "onSubmits" in order for a form to be validated?' |
-- div -->
|