Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
265 views
in Technique[技术] by (71.8m points)

forms - 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)

question from:https://stackoverflow.com/questions/11761202/whats-the-difference-between-novalidate-and-formnovalidate-attributes-of-html5

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...