What's the difference between novalidate and f

2020-02-19 03:06发布

问题:

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)

回答1:

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.



标签: forms html