The select()
method selects the content of a password field.
The select()
method is supported in all major browsers.
select |
Yes | Yes | Yes | Yes | Yes |
passwordObject.select()
None.
No return value.
The following code shows how to select the content of a password field.
<!DOCTYPE html>
<html>
<body>
<!-- w w w .j av a 2s. c om-->
Password: <input type="password" id="myPsw" value="abc12345">
<button type="button" onclick="myFunction()">test</button>
<script>
function myFunction() {
document.getElementById("myPsw").select();
}
</script>
</body>
</html>
The code above is rendered as follows: