0

I'm using the jQuery validation plugin. When I click the 'My btn' button the form needs to submit without validation. Even if the title is empty it should be able submit by only clicking the 'My btn' button. Is there any way to do this?

<form class="callBkfrm" method="POST" action="/my_action">
  <input type="text" name="title" />
  <button class='btn' type="button">My btn</button>
  <button type="submit">Submit</button>
</form>
$(".myFrm").validate({
  rules: {
    title: {
      required: true
    },
  }
});
1

1 Answer 1

2

From the jquery-validate reference*:


Skipping validation on submit

To skip validation while still using a submit-button, add the attribute formnovalidate to that input:

<input type="submit" name="go" value="Submit">
<input type="submit" formnovalidate name="cancel" value="Cancel">

This used to work by adding class="cancel" to the input, this is now deprecated.

Demo for the cancel button

*copied here for reference

Sign up to request clarification or add additional context in comments.

1 Comment

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.