How do user agents handle the required HTML5 attribute?

This is probably a bit of a question about the Nob, so apologize in advance, but ... Does the HTML5 specification define how user agents should respond to the required HTML5 attribute (or it depends on them)? In other words, are there any specific rules that define how user agents should behave (for example, “users should be warned about the availability of the required field”; “when the user submits the form, the required controls should be checked and messages errors are displayed in an event in which they do not matter, etc.)

The HTML5 specification seems to contain some vague recommendations, but nothing concrete.

+4
source share
1 answer

The specification states that when the required element has a value, which is an empty string:

element is missing

If we look at the "Constraints" section (which explains what it means "missing"), it tells us:

An item may have a certain validity error message. Initially, the element should have its own set of authentication error messages to an empty string. When its value is not an empty string, the element suffers from a user error. It can be set using setCustomValidity() . The user agent must use the user confidence error message when warning the user about a problem with management .

It makes sense to leave the exact implementation of how to display this message to browsers so that they can fit it into their current styles and user interface.

There are examples (screenshots) of how browsers handle it differently here , as well as information about browser compatibility:

enter image description here

+5
source

Source: https://habr.com/ru/post/1433795/


All Articles