Latest web development tutorials

HTML DOM Input Email required properties

Input Email Object Reference Input Email Object

Examples

View email field before submitting the form if required fields:

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

try it"

Definition and Usage

required property sets or returns the email field in the form if a required field.

This property reflects the HTML required attributes.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the required properties, in addition to Internet Explorer 9 and earlier versions of IE, Safari browser.

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


grammar

Returns required attributes:

emailObject .required

Set the required properties:

emailObject .required=true|false

Property Value

描述
true|false 描述了 email 字段在表单提交前是否为必填部分。
  • true - email 字段为表单的必填部分
  • false - 默认。 email 字段为表单的选填部分。

technical details

return value: Boolean value that, if the email fields are required parts of the form back to true, otherwise false.


More examples

Examples

Set email fields to the form required parts:

document.getElementById("myEmail").required = true;

try it"


Related Pages

HTML Reference Manual: HTML <the INPUT> required Attribute


Input Email Object Reference Input Email Object