jQuery Validate - resetForm() Not Behaving as Expected

Posted by Kevin C. on Stack Overflow See other posts from Stack Overflow or by Kevin C.
Published on 2010-05-04T02:42:11Z Indexed on 2010/05/04 2:48 UTC
Read the original article Hit count: 430

Site in question is http://epraxadev.com/kw/palisade-palms/

"Click here for brochure" and "Learn More about Palisade Palms" both bring up a lightbox with the same HTML form to be filled out...the "learn more..." link also changes some of the HTML in the form (the value for a hidden form field, and the fields required).

I'm using Colorbox for the lightbox, and for its onClosed event, I have this to reset the form:

onClosed: function() {
        $('#brochure-form label em').remove();
        $('#brochure-form').data('validator').resetForm();
    }

Now here's the problem:

  • User tries to submit the "brochure" form, but it fails validation. User closes the lightbox.
  • User opens up the "Learn more" lightbox, and tries to submit the form...now, instead of using the correct validation rules (only requiring e-mail and referrer), it requires all fields to be filled out (as is the case with the "Brochure Form")

Is there something that I can add to the onClosed function, to clean up all the validation rules?

Thanks guys!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery