Latest web development tutorials

HTML DOM Input Text required properties

Input Text Object Reference Input Text Object

Examples

Check whether the text field before submitting filled:

var x = document.getElementById ( "myText") required.;

x The output is:

true

try it"


Definition and Usage

required property sets or returns whether the text field must be filled in before submitting.

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 browser, Safari.


grammar

Returns required attributes:

textObject .required

Set the required properties:

textObject .required = true | false

Property Value

value description
true | false It specifies whether the text field is a required part of the form submission.
  • true - text field is a required part of the form submission
  • false - default. Required text fields are not part of the form submission
technical details
return value: Boolean value, if a required part of the text field to the form submission returns true, false otherwise


More examples

Examples

Setting text field is a required part of the form submission:

. Document.getElementById ( "myText") required = true;

try it"


Related Pages

HTML Reference Manual: HTML <the INPUT> required Attribute


Input Text Object Reference Input Text Object