Change the placeholder text of a password field:
document.getElementById("myPassword").placeholder = "Type your password";
Click the button to change the placeholder text of the password field.
<!DOCTYPE html> <html> <body> Password: <input type="password" id="myPsw" placeholder="Psw.."> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from www.j av a 2s .c om*/ document.getElementById("myPsw").placeholder = "Type your password"; } </script> </body> </html>
The placeholder property sets or gets the placeholder attribute of a password field.
The placeholder attribute sets a hint message for a password field.
The short hint is displayed in the password field before the user enters a value.
The placeholder property accepts and returns a String type value.