Javascript DOM HTML Input Email type Property get

Introduction

Return which type of form element the email field is:

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

Click the button to return which type of form element the email field is.

View in separate window

<!DOCTYPE html>
<html>
<body>

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

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

<script>
function myFunction() {/*from   w  w  w.j av  a2s  . c om*/
  var x = document.getElementById("myEmail").type;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The type property returns which type of form element the email field is.

For an input type="email", this property will always return "email".




PreviousNext

Related