javascript - Can I programmatically instruct parsleyJS to ignore a validation group? -
i have 2 step form validated parsleyjs.
the second step credit card details form. however, required if option selected in part 1 of form. possible toggle between free , paid accounts.
how can tell parsley ignore validation second group of inputs in js?
here relevant snippet
var free = package.data('package-cost') * 1 <= 0; //validate step on if ($('form.register-form').parsley().validate($('.reg-step.active').data('parsley-group'))) { var form = $(this); if(free){ //submit free registration - need ignore validation of group 'step2' in here before submitting form.get(0).submit(); } else{ // disable submit button prevent repeated clicks form.find('button').prop('disabled', true); // prevent form submitting default action return false; } }
if select field, add change event handler select field, when selected, set data-attribute of fields dont want validate ,
$(yourselect).on('change', function() { if (this.value == 'your-value-where-validation-shouldnt-be-done') $('your-form-step-2-fields').data('parsley-excluded',true); });
Comments
Post a Comment