13

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.

1
  • 2
    Perhaps the jQuery trigger() method may be of use? Commented Jun 19, 2011 at 19:39

3 Answers 3

27
$("#myButton").click(function(e) {
    e.preventDefault();
    if($("#myform").valid()){
        // the form is valid, do something
    } else{
        // the form is invalid
    }
});
Sign up to request clarification or add additional context in comments.

Comments

4

You can use this

$(".selector").validate({
   submitHandler: function(form){
    form.submit();
   }
});

which autosubmits the form it is valid, so you .validate() instead of submit()

Comments

4

You could try this:

$('#someForm').valid();

which could also be done in the submit handler:

$('#someForm').submit(function() {
    if ($(this).valid()) {

    } else {

    }
});

1 Comment

@Mikkel, the .valid() method returns a boolean indicating whether the form is valid or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.