Input Number required Attribute
Definition and Usage
required
Sets or returns whether the numeric field must be filled out before submitting the form.
This property reflects the HTML required attribute.
See also:
HTML Reference Manual:HTML <input> required Attribute
Example
Example 1
Check if the numeric field must be filled out before submitting the form:
var x = document.getElementById("myNumber").required;
Example 2
Set the numeric field as a required part of the form submission:
document.getElementById("myNumber").required = true;
Syntax
Return the required attribute:
numberObject.required
Set the required attribute:
numberObject.required = true|false
Attribute value
Value | Description |
---|---|
true|false |
Specify whether the numeric field should be a required part of the form submission.
|
Technical Details
Return value: | Boolean value, returned if the numeric field is a required part of the form submission true ; otherwise return false . |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Supported | 10.0 | Supported | Not Supported | Supported |