Input Search requiredProperty
Example
Check whether the search field is a required field before submitting the form:
var x = document.getElementById("mySearch").required;
xThe output result is:true
Try it Yourself »
Definition and Usage
The required property is used to set or return whether the search field is a required field in a form.
This property reflects the HTML required attribute.
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the required attribute, except Internet Explorer 9 and earlier IE versions, and Safari.
Syntax
Return the required property:
searchObject.required
Set the required property:
searchObject.required=true|false
Property 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, 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 Yourself »
Related Pages
HTML Reference:HTML <input> required Attribute
Other Extensions
Input Search Object