Input URL requiredProperty
Examples
Check whether the URL field is required before submitting the form:
var x = document.getElementById("myURL").required;
xThe output result is:true
Try it Yourself »
Definition and Usage
The required property is used to set or return whether the URL field is required 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:
urlObject.required
Set the required property:
urlObject.required=true|false
Property Values
| Value | Description |
|---|---|
| true|false | Describes whether the URL field is a required part of the form before it is submitted.
|
Technical Details
| Return value: | A Boolean value, returns true if the URL field is a required part of the form, otherwise returns false. |
|---|
More Examples
Examples
Set the URL field as a required part of the form:
document.getElementById("myURL").required = true;
Try it Yourself »
Related Pages
HTML Reference Manual:HTML <input> required Attribute
Input URL Object Other Extensions