Open In App

HTML DOM Input Tel required Property

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:



telObject.required
telObject.required = true|false

Property Values:

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.




<!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:

Article Tags :