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 ponent. I am using primefaces 3.0 and jsf 2.0.
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 ponent. I am using primefaces 3.0 and jsf 2.0.
Share Improve this question edited Jun 27, 2012 at 5:46 Jigar Joshi 241k42 gold badges409 silver badges446 bronze badges asked Jun 27, 2012 at 5:40 MuthuMuthu 2793 gold badges9 silver badges23 bronze badges1 Answer
Reset to default 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";
}
}