Easy Tutorial
❮ Prop Meter High Prop Tabledata Choff ❯

Input Search required Attribute

Input Search Object

Example

Check if the search field is a required field before submitting the form:

var x = document.getElementById("mySearch").required;
true

Definition and Usage

The required attribute is used to set or return whether the search field is a required field 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 Safari.


Syntax

Return the required attribute:

Set the required attribute:

Attribute Values

Value Description
true false Describes whether the search field is a required part of the form before submission. true - The search field is a required part of the form. <br> false - Default. The search field is an optional part of the form.

Technical Details

| Return Value: | Boolean, returns true if the search field is a required part of the form, otherwise returns false. | | --- | --- |


More Examples

Example

Set the search field as a required part of the form:

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

Related Pages

HTML Reference: HTML <input> required Attribute


Input Search Object

❮ Prop Meter High Prop Tabledata Choff ❯