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' );
Share it with your friends, thanks !
Share on FacebookTweet about this on TwitterShare on Google+Share on TumblrBuffer this pagePin on PinterestEmail this to someone

You may also like...

  • Oscar R.

    Good post, the piece of code:

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

    Helped me to validate form fields on the fly. Gonna post this in my blog with a fully functional example
    and will link this entry there.

    Thank you very much.

    • Oscar , glad that help !