JQuery validation plugin and forms

I am working with a jQuery form plugin and jQuery Validation plugin:

Form: http://jquery.malsup.com/form/ Validation: http://bassistance.de/jquery-plugins/jquery-plugin-validation/

I am trying to work with both of them to play well, in terms of document validation, THEN submit using the jQuery plugin.

Any ideas?

+7
jquery ajax validation forms
source share
2 answers

from docs :

 $ (". selector"). validate ({
    submitHandler: function (form) {
     $ (form) .ajaxSubmit ();
    }
 })
+10
source share

According to http://malsup.com/jquery/form/#validation you can use the beforeSubmit parameter to provide a callback that returns true or false.

In this callback, just use the plugin method .valid () described here http://jqueryvalidation.org/valid

$(document).ready(function() { // jQuery Validation Plugin $("#myForm1").validate(); // jQuery form Plugin var options = { target: '#output1', // target element(s) to be updated with server response beforeSubmit: validate, // pre-submit callback success: showResponse // post-submit callback }; // bind form using 'ajaxForm' $('#myForm1').ajaxForm(options); }); // Return validation status from jQuery validate plugin. function validate(formData, jqForm, options) { return $('#myForm1').valid(); } 
+2
source share

All Articles