Input Password size Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Password

Description

The size property sets or gets the size attribute of a password field, which controls the width of a password field in number of characters.

The default value is 20.

Set the size property with the following Values

Value Description
number Sets the width of the password field, in characters. Default value is 20

Return Value

A Number, representing the width of the password field, in characters

The following code shows how to change the width of a password field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Password: <input type="password" id="myPsw">

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

<script>
function myFunction() {// www .  java2s . co m
    document.getElementById("myPsw").size = "50";
}
</script>

</body>
</html>

Related Tutorials