I want to validate a form with parsleyjs.
My problem is I want to validate a block of (3 inputs) only if a input radio is selected.
Here is a image:
By default, no option is selected.
If I choose option 1, nothing need . Validation is ok.
If I choose option 2, I need to validate 3 fields more (I have the validations working: required) only when the option 2 is selected.
I have been reading the docs but could not find the solution.
Solved by myself adding and removing
I finally solved it, by adding
required prop to each input when option 2 is selected, and removing
required prop if option 1 is selected.
// Option 2 $( '#inputId' ).prop( 'required', true ); // Option 1 $( '#inputId' ).prop( 'required', false );