Input Email requiredProperty

Input Email 对象参考手册Input Email Object

Examples

Check whether the email field is required before submitting the form:

var x = document.getElementById("myEmail").required;
xThe output result is:
true

Try it yourself »

Definition and Usage

The required property is used to set or return whether the email field is a required field in the form.

This property reflects the HTML required attribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the required attribute, except Internet Explorer 9 and earlier IE versions, and Safari browser.

Note:Internet Explorer 9 (and earlier IE versions), or Safari browser, does not support HTML <input> elements with type="email".


Syntax

Return the required property:

emailObject.required

Set the required property:

emailObject.required=true|false

Property Values

Value Description
true|false Describes whether the email field is a required part before form submission.
  • true - The email field is a required part of the form
  • false - Default. The email field is an optional part of the form.

Technical Details

Return Value: A Boolean value, 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 yourself »


Related Pages

HTML Reference Manual:HTML <input> required attribute


Input Email 对象参考手册Input Email Object Other Extensions