I have a form that has a normal submit button, but also several ajax methods that submit the form as well. I need to do some pre-save开发者_Go百科 validation stuff. Will the onSubmit function be called every time the form is submitted or do I need to manually call the method before my ajax form submissions?
The onsubmit event only happens when you submit the form manually.
If you call the submit method to submit the form, the onsubmit event is not triggered.
If you are making an AJAX call using the data from the form, the form isn't even submitted at all.
onSubmit is what you want. If you're using AJAX, you should send the request within this method and return false or otherwise stop the default behavior.
加载中,请稍侯......
精彩评论