If the required attribute is present, then the field must contain a value before the form can be submitted.
For example, to make the part number in the previous example required, we’d simply add the required attribute.
For the purpose of the example, let's say a part number consists of three uppercase letters followed by four digits.
The use of pattern ensure that the field value matches the correct format for a part number.
There is even more up to date forms guidance on our new Web Fundamentals site.
Warnings can be displayed when the users response doesn’t match the expected format.
The Java Script validation APIs can provide custom validation logic and prompt users with easy to understand error messages when they’ve provided invalid data.
To do this, add the novalidate attribute to the form element.
In this case, all pseudo classes and Java Script APIs will still allow you to check if the form validates.