javascript - Set default value of a password input so it can be read -
i want have password field says "password" in before user enters password (so know field is)
i'd rather use javascript, importing jquery alone seems wasteful, have no idea how to. images explain quite clearly:
what looks like:
what want like:
it's simple website , basic of logins (has no validation etc)
any ideas?
<input id="username" name="username" class="input_text" type="text" value="username" /> <input id="password" name="password" class="input_text" type="password" value="password" />
change password
input simple input type text
. then, javascript (or jquery) on focus event, change input type password
.
here little untested sample plain javascript (no jquery):
<html> <head> <script type="text/javascript"> function makeitpassword() { document.getelementbyid("passcontainer") .innerhtml = "<input id=\"password\" name=\"password\" type=\"password\"/>"; document.getelementbyid("password").focus(); } </script> </head> <body> <form> <span id="passcontainer"> <input onfocus="return makeitpassword()" name="password" type="text" value="type password" /> </span> </form> </body> </html>
Comments
Post a Comment