Bagata Bagata - 5 months ago 27
HTML Question

What's the difference between novalidate and formnovalidate attributes of HTML5?

From w3c schools we have these definitions:

novalidate:


When present, it specifies that the form-data (input) should not be
validated when submitted.


formnovalidate:


When present, it specifies that the element should not be
validated when submitted.


Does it make any difference using formnovalidate in the submit button insted of using novalidate in the form?

(I really don't get the difference)

Answer

The answer given by @rsplak is not correct. novalidate is applied to the form, and prevents it from being validated; formnovalidate is applied to a submit button, and overrides the novalidate option, if present; it means 'submit this form without validating, regardless of the general form setting'.

The example given in the spec is when a user is saving data rather than publishing it; the data might be incomplete and invalid, but doesn't require validation to be saved.

Comments