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.
<!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".