I'm using Jörn Zaefferer's validate plugin for jquery
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
Is it possible to use this plugin to validate a form, and have the page not reload when the form is submitted?
The plugin, when used ajaxform, allows you to submit the contents of the form via ajax. However, I've already got my own ajax submission functions that I don't want to rewrite.
So far, I've got something like this:
$("#myform").validate({
submitHandler : function(form){
myAjaxSubmissionFunction() ;
}
});
This is fine, but when validation passes and the submit button is clicked, the page reloads.
Depending on how the submitHandler
is attached to the form submission event, you could try adding return false;
at the end of the function body.
There is an ajax form plugin for jquery .
I think you should add this:
$("#myform").submit(function(event){
event.preventDefault();
});
This will prevent the form to be submitted normally, so only your ajax submission will run.
Hope this helps. Cheers
Add a return false
at the end of function myAjaxSubmissionFunction .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.