Javascript DOM HTML Input Email name Property get

Introduction

Get the name of an email field:

var x = document.getElementById("myEmail").name;

Click the button to return the value of the name attribute of the email field.

View in separate window

<!DOCTYPE html>
<html>
<body>

E-mail: <input type="email" id="myEmail" name="usremail">
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/* w w w. j  a  v  a  2  s  .c  o m*/
  var x = document.getElementById("myEmail").name;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The name property sets or gets the value of the name attribute of an email field.

The name attribute can identify form data after submitting to the server.

The name property accepts and return a String value.




PreviousNext

Related