The input required attribute indicates that an input field must be completed before the form can be submitted.
This attribute is applicable to the following input types: text, search, url, tel, email, password, date pickers, number, checkbox, radio, and file.
Example
An input field that is mandatory:
<form> <label for=”username”>Username:</label> <input type=”text” id=”username” name=”username” required> </form> |
The step
attribute sets the allowed numerical intervals for an input field, such as step=”3″ allowing values like -3, 0, 3, 6, etc. It works with min
and max
attributes to define a valid range and is compatible with input types like number, date, and time.
Example
An input field with defined allowable numerical intervals:
<form> <label for=”points”>Points:</label> <input type=”number” id=”points” name=”points” step=”3″> </form> |