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.
Data validation doesn’t just help to keep your data clean, but it also helps improve the user experience.
For example, datalists can provide auto-complete in text boxes suggesting options to the user.
You can use standard HTML5 attributes to validate input, or you can make your own validation functions.
The Angular JS directive ng-model binds the input elements to the model.
You can also use the min and max attributes on any of the date type inputs.
There is even more up to date forms guidance on our new Web Fundamentals site.
For example, if you want to limit a filename to 12 characters, you can use the following.
In some cases, you may want to allow the user to submit the form even if it contains invalid input.
On other elements, you can indicate a valid input format by providing a regular expression in the the pattern attribute.
For more information, be sure to read the section on Validation.