Javascript DOM HTML Input Password size Property get

Introduction

Get the width of a password field:

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

Click the button to display the value of the size attribute.

View in separate window

<!DOCTYPE html>
<html>
<body>

Password: <input type="password" id="myPsw" size="30">
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {/*from w  w w . j  a  v a  2s .c o m*/
  var x = document.getElementById("myPsw").size;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related