HTML DOM Input Email type Property

HTMLWeb DevelopmentFront End Technology

The HTML DOM Input Email type property returns/sets type of Input Email.

Syntax

Following is the syntax −

  • Returning string value
inputEmailObject.type
  • Setting type to string value
inputEmailObject.type = stringValue

String Values

Here, “stringValue” can be the following −

stringValueDetails
emailIt defines that input type is email
datetime-localIt defines that input type is datetime-local
radioIt defines that input type is radio
telIt defines that input type is tel and a number keypad is shown for input

Example

Let us see an example of Input Email type property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>Input Email type</title>
<style>
   form {
      width:70%;
      margin: 0 auto;
      text-align: center;
   }
   * {
      padding: 2px;
      margin:5px;
   }
   input[type="button"] {
      border-radius: 10px;
   }
</style>
</head>
<body>
<form>
<fieldset>
<legend>Email-type</legend>
<label for="EmailSelect"></label>
<input type="email" id="EmailSelect" >
<input type="button" onclick="getTypeOfInput()" value="What to enter?">
</fieldset>
</form>
<script>
   var labelSelect = document.querySelector("label");
   var inputEmail = document.getElementById("EmailSelect");
   function getTypeOfInput() {
      labelSelect.innerHTML = inputEmail.type.toUpperCase()+' ID: ';
   }
</script>
</body>
</html>

Output

This will produce the following output −

Before clicking ‘What to enter?’ button −

After clicking ‘What to enter?’ button −

raja
Published on 25-Jul-2019 14:14:21
Advertisements