开发者

Does OnSubmit Run Every Way a Form is Submitted or Just When the Submit Button is Clicked?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜