Javascript Reference - HTML DOM Input Password select() Method








The select() method selects the content of a password field.

Browser Support

The select() method is supported in all major browsers.

select Yes Yes Yes Yes Yes

Syntax

passwordObject.select() 

Parameters

None.

Return Value

No return value.





Example

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: