Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

Form validation attributes

99% of the times we want to validate each input field separately. This make sense because not all the inputs of a form are the same. Thus, we validate differently based on the type of the information, we are asking from the user to fill in.

Validating through every input is possible by adding to this input specific attribute keywords with corresponding values to the HTML elements. Some of these attributes are shown above, and they can vary depending on what do we ask from this field. We can specify that this field should be required, so that the user cannot ignore it, or define a range of accepted values (for example age more than 18), combinations are also possible and many many more.

Bear in mind, that not all attributes are destined to work with all types of inputs. Some are bound to specific input. 

In the end we can apply also an attribute to the form element itself, This is the novalidate attribute. By default a form will validate every input to check if the data is valid or not before submitting. Unless we put the novalidate attribute to the form element. Then regardless of what validate keyword every input has, the form will not be validated at all and we accept everything.

If you want to check all the input attributes of a form, do it here.