Web Analytics Made Easy -
StatCounter Change input type?? - CodingForum

Announcement

Collapse
No announcement yet.

Change input type??

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Change input type??

    Is it possible to change the input type of a form field.

    example

    <input type="password" name="pw" value="test">

    i want to have a "view" button next to that field that when you press and hold it it will chnage that input type to "text" so i can see the password. And when i release the button it will change it back.

    I know this sounds like a bad idea and insecure... but its not a big deal.. i have all this stored in an "administrator" panel which an admin must login to get to it. Inside of that i have some admin programs, one of which displays information about the clients. I want to be able to see the clients password when ever i need to reference what it is, but i figured rather then just printing it on the screen all the time this would be a better way.

    Any suggestions?

  • #2
    rough e.g.

    js
    Code:
    function showPass() {
    	
    	var trgtInput = document.getElementById('pw');
    	trgtInput.onmousedown = function() { this.type = 'text'; }
    	trgtInput.onmouseup = function() { this.type = 'password'; }
    	trgtInput.onmouseout = function() { this.type = 'password'; }
    	
    }
    
    window.onload = showPass;
    markup
    Code:
    …
    
    <input type="password" name="pw" id="pw" value="test">
    
    …
    You can just click and hold on the input text itself and the text will become clear whilst you have the button down. When you release the mousebutton whilst still over the input or move the cursor out of the area of the input, the text will return to using the password bullets.

    HTH
    Why you should validate your code before asking for help...

    Comment


    • #3
      change input type text to password(it will work definitely)

      function change_type() {

      if(navigator.appName == "Netscape")
      {
      document.getElementById('pwd').value='';
      document.getElementById('pwd').type='password';
      }
      if(navigator.appName == "Microsoft Internet Explorer")
      {
      document.getElementById('pass').innerHTML='';
      document.getElementById('pass').innerHTML='<input type="password" name=pwd class=textbox_nobrdr>';
      document.getElementById('pwd').focus();
      document.getElementById('pwd').focus();
      }
      else
      {
      document.getElementById('pwd').value='';
      document.getElementById('pwd').type='password';
      }
      }

      Comment

      Working...
      X