Input Email required property
Example
Check whether the email field is required before submitting the form:
var x = document.getElementById("myEmail").required;
x
The output is:
true
Try it »
Definition and Usage
The required property is used to set or return whether the email field is required in the form.
This attribute reflects the HTML required attribute.
Browser support





All major browsers support the required attribute, except Internet Explorer 9 and earlier versions and the Safari browser.
Note: Internet Explorer 9 (and earlier IE versions) or Safari browser does not support the HTML element with type="email". .
Syntax
Return the required attribute:
emailObject
.required
Set the required attribute:
emailObject
.required=true|false
Attribute values
| Value | Description |
|---|---|
| true|false | Describes whether the email field is a required part before the form is submitted.
|
Technical Details
| Return Value: | 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;
Try it »
Related pages
HTML Reference Manual: HTML required attribute
Input Email Object