Input Number requiredProperty
Example
Check whether the number field is required before submitting the form:
var x = document.getElementById("myNumber").required;
xThe output result is:true
Try it yourself »
Definition and Usage
The required property is used to set or return whether the number field is a required field in the form.
This property reflects the HTML required attribute.
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the value property.
Note:Internet Explorer 9 and earlier IE versions do not support <input> elements with the type="number" attribute.
Syntax
Return the required property:
numberObject.required
Set the required property:
numberObject.required=true|false
Property Values
| Value | Description |
|---|---|
| true|false | Describes whether the number field is a required part before form submission.
|
Technical Details
| Return Value: | A Boolean value, returns true if the number field is a required part of the form, otherwise returns false. |
|---|
More Examples
Example
Set the number field as a required part of the form:
document.getElementById("myNumber").required = true;
Try it yourself »
Related Pages
HTML Reference Manual:HTML <input> required attribute
Input Number Object Other Extensions