YouTip LogoYouTip

Prop Url Required

HTML DOM Input URL required Attribute

HTML DOM Input URL required Attribute

HTML DOM Input URL required Attribute

-- Learning not just skills, but dreams!

JavaScript Reference

Overview

JavaScript Objects

JavaScript Array Object JavaScript Boolean Object JavaScript Date Object JavaScript Math Object JavaScript Number Object JavaScript String Object JavaScript RegExp Object JavaScript Global Properties/Functions JavaScript Operators JavaScript Error

Browser Objects

Window Object Navigator Object Screen Object History Object Location Object Storage Object

DOM Objects

HTML DOM Document Object HTML DOM Element Object HTML DOM Attribute Object HTML DOM Event Object HTML DOM Console Object CSSStyleDeclaration Object DOM HTMLCollection

HTML Objects

<a> <area> <audio> <base> <blockquote> <body> <button> <canvas> <col> <colgroup> <datalist> <del> <details> <dialog> <embed> <fieldset> <form> <iframe> <frameset > <img> <ins> <input> - button <input> - checkbox <input> - color <input> - date <input> - datetime <input> - datetime-local <input> - email <input> - file <input> - hidden <input> - image <input> - month <input> - number <input> - range <input> - password <input> - radio <input> - reset <input> - search <input> - submit <input> - text <input> - time <input> - url <input> - week <keygen> <link> <label> <legend> <li> <map> <menu> <menuItem> <meta> <meter> <object> <ol> <optgroup> <option> <param> <progress> <q> <script> <select> <source> <style> <table> <td> <th> <tr> <textarea> <title> <time> <track> <video>

<input> - time <input> - week

Explore Further

Software

Programming Languages

Programming

Web Design and Development

Web Service

Development Tools

Scripting Languages

Scripting

Computer Science

Web Services

Input URL required Attribute

Input URL Object Reference Input URL Object

Example

Check if the URL field is required before submitting the form:

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

x output will be:

true

Try it Β»


Definition and Usage

The required property sets or returns whether the URL field in a form must be filled out before submitting the form.

This property reflects the HTML required attribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

The required property is supported in all major browsers, except Internet Explorer 9 and earlier, and Safari.


Syntax

Return the required property:

urlObject.required

Set the required property:

urlObject.required=true|false

Property Values

Value Description
true|false Specifies whether the URL field must be filled out before submitting the form.
  • 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. 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: HTML <input> required Attribute


Input URL Object Reference Input URL Object

← Prop Url SizeProp Url Required β†’