Reputation: 717
I have i form i submit via jQuery's .submit(), unfortunately it does not trigger the validation plugin when i do it this way. If i place a submit button inside the form, it works perfectly.
Is there someway to trigger the plugin manually?
Thanks in advance.
Upvotes: 13
Views: 20775
Reputation: 1038730
You could try this:
$('#someForm').valid();
which could also be done in the submit handler:
$('#someForm').submit(function() {
if ($(this).valid()) {
} else {
}
});
Upvotes: 4
Reputation: 45589
$("#myButton").click(function(e) {
e.preventDefault();
if($("#myform").valid()){
// the form is valid, do something
} else{
// the form is invalid
}
});
Upvotes: 27
Reputation: 6136
You can use this
$(".selector").validate({
submitHandler: function(form){
form.submit();
}
});
which autosubmits the form it is valid, so you .validate() instead of submit()
Upvotes: 4