最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how can i toggle a <p:password> field to text and password with a checkbox check uncheck - Stack Over

programmeradmin3浏览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.

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 badges
Add a ment  | 

1 Answer 1

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";
  }
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论