Tips for using Parsleyjs

I been using parsley.js recently for some complex form validation , just want to share some of the tips that help.

1. If you checking on radio or checkbox as required field, using the min-check validation rather than using required validation.

2. if you just need to validate field that are visible, don’t use the auto validation, write the parsley function that kick in before submit, add checking element is visible on the listener.

3. For select input that having default value, if you need to check there are valid value selected , add the function on validators , to make sure there is value available for the input option.

4.  Last if you want to add validation on the fly for certain field, you can use

$( '#field' ).parsley( 'addConstraint', { required: true } );

to remove the “required” validation on the fly.

$( '#field' ).parsley( 'removeConstraint', 'required' );

You may also like...