0

I have two buttons, one for Next and one for SAVE when clicking Next I would like to let jQuery do its validation, but when SAVE is CLICKED jQuery will not do its validation. Are there event handlers for this?

0

3 Answers 3

7

The jQuery Validation plugin will automatically capture/validate on any button or input (within the <form></form> container) with type="submit" and ignore any with type="button".

<button type="submit">NEXT</button>
<button type="button">SAVE</button>

OR

<input type="submit" value="NEXT" />
<input type="button" value="SAVE" />

Alternatively, adding a class="cancel" to the button will cause the plugin to ignore it.

<button type="submit">NEXT</button>
<button type="submit" class="cancel">SAVE</button>

OR

<input type="submit" value="NEXT" />
<input type="submit" class="cancel" value="SAVE" />
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the tip, it's found in the jquery.validate.js // allow suppresing validation by adding a cancel class to the submit button this.find("input, button").filter(".cancel").click(function() { validator.cancelSubmit = true; });
-1
$("#nextButtonId").click(validateFunction);
$("#saveButtonId").click(saveFunction);

Something like this would work

Comments

-1

Set up two functions next() and save() where you would use validate() in next() and skip the validation in save().

If you provided some code we could help you further.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.