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
  • min
  • max
Set the minimum and maximum values for numerical input
type Specify the data type:
  • Number
  • Email address
  • Other predefined type, like a button, a checkbox, or a text field
For a full list of types, see The Input Form Element
pattern Specifies a regular expression that defines the pattern for the form field data
For in-depth information on built-in form validation, see Client-side Form Validation.

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. 
<input type="text" name="vars[first_name]" required title="Enter your first name" />