Created
          June 26, 2012 17:47 
        
      - 
      
 - 
        
Save computercarguy/2997403 to your computer and use it in GitHub Desktop.  
    JavaScript to create a password field that initially has the visible word Password in the field, but then becomes an HTML password field when clicked, and reverts to the text field that says Password if left blank.
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function Focus2(){ | |
| HTMLCode = "<input type=\"password\" size=\"20\" id=\"mypassword\" name=\"mypassword\" "; | |
| HTMLCode += "onkeydown='javascript:if(event.keyCode==13){Login();}' onblur=\"Blur2()\" />"; | |
| document.getElementById("thepassword").innerHTML = HTMLCode; | |
| document.getElementById("mypassword").focus(); | |
| document.getElementById("mypassword").focus(); | |
| } | |
| function Blur2(){ | |
| if ((document.getElementById("mypassword").value == "") || (document.getElementById("mypassword").value == null)) { | |
| document.getElementById("thepassword").innerHTML = "<input type=\"text\" size=\"20\" value=\"Password:\" onclick=\"Focus2()\" onselect=\"Focus2()\" />"; | |
| } } | |
| // X/D/HTML to set up the password area, can use something other than a span of course | |
| <span name="thepassword" id="thepassword"><input type="text" size="20" value="Password:" onclick="Focus2()" onfocus="Focus2()" /></span> | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment