1

I wrote a small script which copies the billing address to the delivery address form fields onclick of a checkbox.

I have added validate.resetForm(); as suggested here: to ensure that the current form errors are cleared.

This doesn't seem to be working and clearing no errors.

Example: http://jsfiddle.net/c5Qkt/

Steps:

  1. Click the "Save" button, displays error messages.
  2. Enter details in "Billing Address"
  3. Check the "Same as Booking information"

How can I clear all errors and maybe even re-validate the form after click the checkbox?

0

1 Answer 1

3

Your problem is that resetForm is a method on the validator object returned by validate.validate(...), and not on the jQuery object itself. Fixed fiddle http://jsfiddle.net/pjucc/

var theForm = $(".validate");
var validate = null;
if (theForm.length) {
    validate = theForm.validate({ ... });
}
:
validate.form();

The function you want to trigger validation instead is .form()

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

1 Comment

Heh, I'm sure we've all done worse. It's not amazingly clear from their docs either - I ended up reading the jquery.validator.js code.

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.