Skip to content
Related Articles
Open in App
Not now

Related Articles

HTML DOM Input Tel required Property

Improve Article
Save Article
  • Last Updated : 29 Aug, 2022
Improve Article
Save Article

The DOM input tel required property in HTML DOM is used to set or return whether the input tel field should be filled or not when submitting the form. This property is used to reflect the HTML required attribute.

Syntax:

  • It returns the input tel required property. 
telObject.required
  • It is used to set the input tel required property. 
telObject.required = true|false

Property Values:

  • true: It specifies that the input field must be filled out before submitting the form.
  • false: It is the default value. It specifies that the input tel field must not be filled out before submitting the form. 

Return Value: It returns a Boolean value which represents that the number field must be filled or not before submitting the form.

Example: This example illustrates how to return input tel required property.

HTML




<!DOCTYPE html>
<html>
<body style="text-align:center;">
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
    <h2>DOM Input Tel required property</h2>
    <legend>
        Phone Number:
        <input type="tel" id="mytel"
            value="6753682635" required>
    </legend>
    <br><br>
    <button onclick="check()">
        Check!
    </button>
    <p id="demo"></p>
 
    <script>
        function check() {
            var x = document.getElementById("mytel").required;
            document.getElementById("demo").innerHTML = x;
        }
    </script>
</body>
</html>


Output:           

 

Supported Browsers:

  • Google Chrome 3+
  • Edge 12+
  • Firefox
  • Opera 11+
  • Safari 4+
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!