Javascript DOM HTML Input Email size Property get

Introduction

Display the width of an email field in number of characters:

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

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

View in separate window

<!DOCTYPE html>
<html>
<body>

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

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

<script>
function myFunction() {//from   ww w  .  j a va2s . c o m
  var x = document.getElementById("myEmail").size;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related