guillaumepotier / Parsley.js

Validate your forms, frontend, without writing a single line of javascript
http://parsleyjs.org
MIT License
9.04k stars 1.3k forks source link

Toggling validation through javascript causes errors on checkboxes and radio lists #373

Closed TheMonk closed 10 years ago

TheMonk commented 11 years ago

I've written a plugin that extends Parsely and adds conditional logic. However I've found an error in Parsely when toggling required fields. Take a look at the url below and follow the steps below to reproduce. Note that I've also recorded a video that shows the error and also the console output which confirms the issue.

Here's the url: http://monkinteractive.com/parsely/

  1. Click submit to display the error message
  2. Click "remove validation"
  3. Click "add validation"
  4. Click submit again to show the error
  5. Click "remove validation" 6 Click submit again, this time the validation is still applied even though it should no longer be active on the field.

The only way to remove the validation is to do the following:

  1. Check off an option in the checkboxes
  2. Click remove validation It's now fixed.

From what I can tell by checking off an option on the checklist it causes the removeItem method to run twice. Since the first time the hash comes up with a random string, it then proceeds to the second item in the checklist array.

Have a look at the video below for details, it's a recording of my desktop displaying the problem, the function itself and the console output. http://monkinteractive.com/parsely/error-video.mp4

This happens only with lists of checkboxes or radio buttons.

This problem is critical to the plugin I've developed since it loops through the form when the page loads, disabling all required fields via JavaScript, then renabling them as required.

guillaumepotier commented 10 years ago

Hi,

Parsley 2.0 is out. I do not support anymore 1.x versions and related issues here.

Please, see if 2.0 fix your concern. If not, feel free to ask for help on StackOverflow, there is a #parsley.js tag.

Thanks