Input Search required Property
Example
Check whether the search field is required before submitting the form:
var x = document.getElementById("mySearch").required;
x
The output is:
true
Try it »
Definition and Usage
The required property sets or returns whether the search field is required 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 the Safari browser.
Syntax
Return the required attribute:
searchObject
.required
Set the required attribute:
searchObject
.required=true|false
Attribute values
| Value | Description |
|---|---|
| true|false | Describes whether the search field is a required part before the form is submitted.
|
Technical Details
| Return Value: | A Boolean value that 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;
Try it »
Related pages
HTML Reference Manual: HTML required attribute
Input Search Object