Password select()Method
Password Object
Definition and Usage
The select() method is used to select the text in a password field.
Syntax
passwordObject.select()
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the select() method.
Example
Example
The following example selects the text in a password field:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example (example.com)</title>
<script>
function myFunction(){
document.getElementById("pwd").select();
}
</script>
</head>
<body>
<form>
Password: <input type="password" id="pwd" value="thgrt456">
</form>
<button type="button" onclick="myFunction()">Select</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Example (example.com)</title>
<script>
function myFunction(){
document.getElementById("pwd").select();
}
</script>
</head>
<body>
<form>
Password: <input type="password" id="pwd" value="thgrt456">
</form>
<button type="button" onclick="myFunction()">Select</button>
</body>
</html>
Try it yourself »
Password Object Other Extensions