HTML DOM Input Email required Attribute
The required attribute is used to set or return whether the email field in a form is required (must be filled out before submission).
Definition and Usage
The required attribute specifies that an input field must be filled out before submitting the form.
This attribute reflects the HTML required attribute.
Browser Support
The required attribute is supported in all major browsers, except Internet Explorer 9 and earlier versions of IE, and Safari.
Note: Internet Explorer 9 (and earlier versions), or Safari do not support the HTML <input> element with type="email".
Syntax
Get the required attribute:
emailObject.required
Set the required attribute:
emailObject.required=true|false
Property Values
| Value | Description |
|---|---|
| true|false | Specifies whether the email field is required before form submission.
|
Technical Details
| Return Value: | A Boolean. Returns true if the email field is a required part of the form, otherwise returns false. |
|---|
More Examples
Example
Set the email field as a required part of the form:
document.getElementById("myEmail").required = true;
Related Pages
HTML Reference: HTML <input> required Attribute
YouTip