Javascript DOM HTML Input Email multiple Property set

Introduction

Set an email field to allow multiple emails:

document.getElementById("myEmail").multiple = true;

Click button to allow multiple emails for the email field on form submission.

Separate each email with a comma, like: mail@example.com, mail2@example.com.

View in separate window

<!DOCTYPE html>
<html>
<body>

<form action="/action_page.php">
  E-mail: <input type="email" id="myEmail" name="usremail">
  <input type="submit">
</form>//w ww.  jav a  2s  .c o m

<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {
  document.getElementById("myEmail").multiple = true;
  document.getElementById("demo").innerHTML = "The email field now accept multiple values.";
}
</script>

</body>
</html>



PreviousNext

Related