2

I am using p:password tag for registration. I want to toggle the field to text when it is checked with check box, it change to password type mode when it is unchecked. How to solve the problem with primefaces component. I am using primefaces 3.0 and jsf 2.0.

jmj
  • 237,923
  • 42
  • 401
  • 438
Muthu
  • 269
  • 3
  • 9
  • 23

1 Answers1

6

under the cover generates the <input type="PASSWORD"/> field (with other attribute name etc..)

So now if you need to show password have a check box like

<input type="checkbox" id="showPassword" onclick="showPassword()"/> Show password

in javascript

function showPassword(){
  var showPasswordCheckBox = document.getElementById("showPassword");
  if(showPasswordCheckBox.checked){
        document.getElementById("ID_FOR_YOUR_PASSWORD_FIELD").type="TEXT";
  }else{
      document.getElementById("ID_FOR_YOUR_PASSWORD_FIELD").type="PASSWORD";
  }
}
jmj
  • 237,923
  • 42
  • 401
  • 438
  • Its work in this format. But i am using how to use this script in this mode – Muthu Jun 27 '12 at 06:56
  • it sends HTML to the browser try checking source of the page – jmj Jun 27 '12 at 08:39
  • I am using Primefaces Lightbox popup window in my application. The problem i am facing is when i click the link to open the corresponding page, its too slow to display the page through light box. Its take more time to loading. How i can i solve it. – Muthu Jun 27 '12 at 11:31
  • You shouldcreate a new question at stackoverflow – jmj Jun 27 '12 at 11:32
  • Don't forget that this code doesn't work in IE. If you want it to work in IE, take a look at [this](http://stackoverflow.com/a/3541516/1057527). – machineaddict Mar 19 '14 at 10:41