HTML <input> Tag with the 'required' Attribute
<form name="myForm" action="/resources/html-forms-action.cfm">
<input name="myInput" required>
<button>Submit</button>
</form>
The above example demonstrates usage of the <input>
element with the required
attribute.
The required
attribute is used for form validation It allows you to specify whether or not the input control is a required field. If it's a required field, the browser will prevent the user from submitting the form until the field contains a value.
Boolean Attribute
The required
attribute is a boolean attribute. If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace (i.e. either required
or required="required"
).
Possible values:
- [Empty string]
- required