Latest web development tutorials

HTML DOM Input Search required properties

Input Search Object Reference Input Search Object

Examples

View search field before submitting the form if required fields:

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

try it"

Definition and Usage

required property sets or returns whether the search field in the form is 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.


grammar

Returns required attributes:

searchObject .required

Set the required properties:

searchObject .required = true | false

Property Value

value description
true | false It describes the search field before the form is submitted if a required part.
  • true - search fields are required parts of the form
  • false - default. Search field for a form of optional parts.

technical details

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


More examples

Examples

Set the search field of the form required parts:

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

try it"


Related Pages

HTML Reference Manual: HTML <the INPUT> required Attribute


Input Search Object Reference Input Search Object