Web Development Course:
- 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|
Guide on PHP Form Validation: How, Why and What Functions to Use
Find tips and tricks on PHP form validation: learn the proper way of using php_self function in your work. PHP form validation example included.
Properties for CSS Form: Learn to Style HTML Input Forms
CSS form guide: learn to easily style HTML forms and with CSS form properties. Find out how to use different CSS input type in your code from examples.