1

I can't figure out how to bypass a form field inside a form when a certain button is clicked.

Example:

In my case, I want to bypass the newpassword and newpassword2 (which is needed if the user wants to change password) because I have a button so the user can delete his account. Without bypass, he has to fill in a newpassword and confirm it before he can delete his account.

These are the id's:

  • Delete button: deletemyacc
  • Form name: updelacc (because update / delete account option within this form)
  • Form field names to bypasss: newpassword and newpassword2

Now this code works, but it skips ALL validations, while I still want the old password form field to be validated and the users email.

$("#deletemyacc").click(function () {
  $("#updelacc").validate().cancelSubmit = true;
});
1
  • Show your HTML and the rest of your jQuery so we can better help. Commented Jan 18, 2013 at 16:00

1 Answer 1

2

Try:

$("#deletemyacc").click(function () {
  $("#updelacc").validate({ignore: ".ignore"}).cancelSubmit = true;
});

this way ignores all elements with class 'ignore'

Source: http://docs.jquery.com/Plugins/Validation/validate#options

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

Comments

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.