Parlseyjs - Remove Validation From Disabled Fields
Solution 1:
After you bind Parsley to your form, it is not enough to remove the attributes. This is because Parsley will create a ParsleyForm
object with the constraints for that form.
Also, the excluded
option will be taken into account at the moment where Parsley is binded to the form. In your case, the fields are not yet disabled, so they will be taken into account for validation purposes.
What you need is to destroy and apply parsley after you have removed the attributes, so ParsleyForm
doesn't containt those fields. If you are using Parsley v2 you should add this code after the removal or insertion of the attributes:
$("#myForm").parsley().destroy();
$("#myForm").parsley();
Also take note, as of jQuery 1.6 the .attr() states
As of jQuery 1.6, the .attr() method returns undefined for attributes that have not been set. To retrieve and change DOM properties such as the
checked
,selected
, ordisabled
state of form elements, use the .prop() method.
So you should use
minage.removeAttr('data-parsley-minagecheck')
.attr('data-parsley-excluded', '').prop('disabled', true);
Post a Comment for "Parlseyjs - Remove Validation From Disabled Fields"