jQuery add required to input fields jQuery add required to input fields javascript javascript

jQuery add required to input fields


You can do it by using attr, the mistake that you made is that you put the true inside quotes. instead of that try this:

$("input").attr("required", true);


I have found that the following implementations are effective:

$('#freeform_first_name').removeAttr('required');$('#freeform_first_name').attr('required', 'required');

These commands (attr, removeAttr, prop) behave differently depending on the version of JQuery you are using. Please reference the documentation here: https://api.jquery.com/attr/