In HTML form contains a number of inputs: text fields, a radio button, a multiple-option select list, a checkbox, and a submit button. These inputs will be validated to ensure that the user has supplied a value for each one.
The validation rules for the form above are as follows:
Field | Validation Rules |
---|---|
Valid string | Required. + Must only contain letters and whitespace |
Valid E-mail | Required. + Must contain a valid email address (with @ and .) |
Valid URL | Optional. If present, it must contain a valid URL |
Input Length | restricts the user to provide the value between the specified range |
Valid Number | alidates that the field will only contain a numeric value. |
Valid String : The code contain only alphabets and whitespace, for example - name. If the name field does not receive valid input from the user, then it will show an error message:
Example :
Valid E-mail : A valid email must contain @ and . symbols. PHP provides various methods to validate the email address.
Example:
Valid URL :In HTML FORM ,If the field does not contain a valid URL, the code will display an error message, i.e., "URL is not valid".
Example :
Input Length : The input length validation restricts the user to provide the value between the specified range, for Example - Mobile Number. A valid mobile number must have 10 digits.
Example:
Valid Number :The below code validates that the field will only contain a numeric value. For example - Mobile no. If the Mobile no field does not receive numeric data from the user, the code will display an error message:
Example :