The min and max attributes can be applied to a form input field to indicate the range of valid values that may be entered into that field. The value of the attribute depends on the type of input field to which it is applied. For instance, an input element of type=”number” can have numeric values specified for its min and max attributes, whereas input type=”date” should have a date value specified such as “1985-05-17”. Invalid values trigger the form’s default validation behavior, which prevents the form from being submitted until all field values contain valid values.

Syntax:

<input type="date" min="1980-01-01" />

<input type="number" min="1" max="100" />

Elements:

NOTE: the validation triggered by the min and max attributes can be bypassed through the use of the novalidate or formnovalidate attributes.

Example

The example using min and max HTML5 attributes:

 

›› go to examples ››