Input URL required property
Example
Check whether the URL field is a required field before submitting the form:
var x = document.getElementById("myURL").required;
x
The output is:
true
Try it »
Definition and Usage
The required property is used to set or return whether the URL field is a required field 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:
urlObject
.required
Set the required attribute:
urlObject
.required=true|false
Attribute values
| Value | Description |
|---|---|
| true|false | Describes whether the URL field is a required part before the form is submitted.
|
Technical Details
| Return Value: | Boolean, returns true if the URL field is a required part of the form, otherwise returns false. |
|---|
More examples
Example
Set the URL field as a required part of the form:
document.getElementById("myURL").required = true;
Try it »
Related pages
HTML Reference Manual: HTML required attribute
The Input URL object