Latest web development tutorials

HTML DOM Input URL required properties

Input URL Object Reference Input URL objects

Examples

See URL field before submitting the form if required fields:

var x = document.getElementById("myURL").required;
x The output is:
true

try it"

Definition and Usage

required property sets or returns the URL field in the form if a required field.

This property reflects the HTML required attributes.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the required properties, in addition to Internet Explorer 9 and earlier versions of IE, Safari browser.


grammar

Returns required attributes:

urlObject .required

Set the required properties:

urlObject .required=true|false

Property Value

value description
true | false It describes the URL field before the form is submitted if a required part.
  • true - URL field of the form required fields
  • false - default. URL field is optional part of the form.

technical details

return value: Boolean value that, if the URL fields are required parts of the form back to true, otherwise false.


More examples

Examples

Set the URL field of the form required parts:

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

try it"


Related Pages

HTML Reference Manual: HTML <the INPUT> required Attribute


Input URL Object Reference Input URL objects