MariniSi MariniSi - 1 year ago 94
jQuery Question

novalidate attribute to specific field or to entire page

How can i set "novalidate" attribute to entire page in the page there are several forms? is this works also for input that are outside form section?

can i set novalidate directly to the input field?

I already tried to set the following attribute in the input field:

<input type="text" ... novalidate>


<input type="text" .. formnovalidate="formnovalidate">

doesn't works!

Can i set the html attribute in any other container?

Answer Source

Well, novalidate property is specific to form elements. So no, you cannot set novalidate automagically to all forms in your page. But you can use a small piece of javascript code to do that for you.

var forms = document.querySelectorAll('form');

for (var i = 0; i < forms.length; i++) {
    forms[i].setAttribute('novalidate', true);

Take a look at this example that I made.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download