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?

Community
  • 1
  • 1
John Magnolia
  • 16,769
  • 36
  • 159
  • 270

1 Answers1

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()

Rup
  • 33,765
  • 9
  • 83
  • 112
  • 1
    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. – Rup Feb 07 '12 at 18:50