HTML DOM Input tel name Property

The input tel name property in HTML DOM is used to set or return the value of the name attribute of an input tel field. The name attribute is required for each input field. If the name attribute is not specified in an input field then the data of that field would not be sent at all.

Syntax:

  • It returns the Input tel name property. 
telObject.name
  • It is used to set the Input tel name property. 
telObject.name = name

Property Values: It contains a single value name that defines the name of the tel field.

Return Value: It returns a string value that represents the name of the tel field.

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

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM Input Tel name property
    </title>
</head>
 
<body style="text-align:center;">
    <h1>w3wiki</h1>
 
    <h2>HTML DOM Input Tel name property</h2>
     
    <legend>
        Phone Number:
        <input type="tel" id="mytel"
            name="Phone Number" value="6753682635"
            required>
    </legend>
    <br><br>
 
    <button onclick="myFunction()">
        Click Here!
    </button>
 
    <p id="result"></p>
 
    <script>
        function myFunction() {
            let x = document.getElementById("mytel").name;
            document.getElementById("result").innerHTML = x;
        }
    </script>
</body>
 
</html>


Output: 

Supported Browsers:

  • Google Chrome 3
  • Edge 12
  • Firefox
  • Opera 11
  • Safari 4