问题
I am trying to put client side validation on the gravity forms. I am newbie to gravity forms, i researched and came to know gravity forms do not support client side validations. SO i decided to do it on my own. I used a validation library by jQuery, when the form is validated, it is not being submitted. I have the following code :-
jQuery(document).ready(function(){
jQuery('#gform_49').validate({ // initialize the plugin
rules: {
input_7: {
required: true,
email: true
},
input_8: {
required: true,
url: true
}
},
submitHandler: function (form) {
form.submit();
return true;
}
});
});
Once validation failed and user then inputs correct data and try to submit the form is not being submitted. However if the user submits all the info correct at first time it works. It seems like gravity forms disables form submission twice. Any idea to submit form after validations are true ?
回答1:
Take out the entire submitHandler
option. It's not needed here since form.submit()
is exactly the default behavior of the plugin. There is also no reason to put return true
inside any of these callback functions.
jQuery(document).ready(function(){
jQuery('#gform_49').validate({ // initialize the plugin
rules: {
input_7: {
required: true,
email: true
},
input_8: {
required: true,
url: true
}
}
});
});
来源:https://stackoverflow.com/questions/25543935/gravity-form-is-not-submitting-after-client-side-validations