- Forms help to submit user inputted information.
- Main form function is to validate data.
- HTML form validation does not work in Internet Explorer 9 or earlier.
HTML Form Validation
HTML form validation can be performed by the browser. If the
This example displays one of the validation functions. It sets the input field
name to be required:
<form action="/action.php" method="post"> <input type="text" name="firstName" required> <input type="submit" value="Submit"> </form>
- Client side validation occurs on the web browser before sending the data to the server.
- Server side validation happens on the server after it receives sent data.
- Constraint validation is a new validation concept based on CSS Pseudo Selectors, HTML Input Attributes, DOM methods and properties.
While it's easy to use, you should be familiar with said attributes and selectors to understand what each of them represents and does. See the tables below, and memorize them to make your work way more manageable.
HTML Input Attributes
|disabled||Defines the element to be disabled|
|max||Defines element's maximum value length|
|min||Defines element's minimum value length|
|pattern||Defines a value's pattern for an element|
|required||Defines an element to be required|
|type||Defines element's type|
|:disabled||Selects all elements with the disabled attribute|
|:invalid||Selects all elements with invalid values|
|:optional||Selects all elements without the required attribute|
|:required||Selects all elements with the required attribute|
|:valid||Selects all elements with valid values|