Input URL required attribute

Definition and Usage

required Attribute settings or returns whether the URL field must be filled out before submitting the form.

This attribute reflects the HTML required attribute.

See also:

HTML Reference Manual:HTML <input> required Attribute

Example

Example 1

Determine whether the URL field must be filled out before submitting the form:

var x = document.getElementById("myURL").required;

Try it yourself

Example 2

Set the URL field as a required part of the form submission:

document.getElementById("myURL").required = true;

Try it yourself

Syntax

Return the required attribute:

urlObject.required

Set the required attribute:

urlObject.required = true|false

Attribute value

Value Description
true|false

The URL field should be a required part of the form submission.

  • true - The URL field is a required part of the form submission
  • false - Default. The URL field is not a required part of the form submission

Technical Details

Return value: Boolean value, if the URL field is a required part of the form submission, it returns true; otherwise return false.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Supported 10.0 Supported Not Supported Supported