Data Validation for HTML
Validate most user data from your HTML forms.
Validation Attributes
Add validation attributes to your form elements to validate user data without Javascript. There are several different attributes you can use:Attribute | Description |
required | Specifies whether a form field is required for submission. Add required to your input field. |
minlength maxlength |
Set the minimum and maximum length for text input |
|
Set the minimum and maximum values for numerical input |
type | Specify the data type:
|
pattern | Specifies a regular expression that defines the pattern for the form field data |
Error Messages
If you'd like to show a more specific error message when the user enters an invalid value or fails to enter a required field, you can add a title attribute and/or the pattern to match in with the required attribute.Copy
<input type="text" name="vars[first_name]" required title="Enter your first name" />