Temporary disable HTML5 “required” attribute

Sometimes when developing, I need to turn off the html5 required so that I my test and implement server side validation. I don’t want to have to remove the attribute from each input element manually, and then have to put them back on. So I use jquery to select the inputs and remove the required attribute.  Then I just delete this line of code when I’m finished testing/developing and wish to turn back on html5 client side required.

// temp for dev
$(“:input”).each(function(){$( this ).removeAttr(“required”);});

Leave a Reply