Input URL requiredProperty

Input URL 对象参考手册Input URL Object

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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.
  • true - The URL field is a required part of the form.
  • false - Default. The URL field is an optional part of the form.

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 对象参考手册Input URL Object Other Extensions