简体   繁体   English

在primefaces + javascript中检查密码是否匹配

[英]check whether password match or not in primefaces + javascript

How can I check whether password match or not in primefaces + javascript? 如何在primefaces + javascript中检查密码是否匹配? I have used like this 我这样用过

function checkPass(){

var pass1 = document.getElementById('password');
var pass2 = document.getElementById('confirmPassword');
lert(pass2);
}

but getting null value! 但是获得空值! In primefaces I called like onkeyup="checkPass(); return false;" 在primefaces中,我调用了onkeyup="checkPass(); return false;"

I don't understand why are you using Primefaces and not take advantage of it's power... 我不明白你为什么使用Primefaces而不是利用它的力量......

There is a password tag in primefaces with a match attribute that matches the strings between two input passwords, also you can get a feedback if a password it's weaker or stronger: 在primefaces中有一个password标签,其match属性与两个输入密码之间的字符串相匹配,如果密码较弱或较强,您也可以获得反馈:

<p:panel header="Match Mode">  
        <p:messages showDetail="true" autoUpdate="true"/>  

        <h:panelGrid columns="2" id="matchGrid">                     
            <h:outputLabel for="pwd1" value="Password 1: *" />  
            <p:password id="pwd1" value="#{passwordBean.password6}" feedback="true" match="pwd2" label="Password 1" required="true"/>  

            <h:outputLabel for="pwd2" value="Password 2: *" />  
            <p:password id="pwd2" value="#{passwordBean.password6}" feedback="false" label="Password 2" required="true"/>  
        </h:panelGrid>  

        <p:commandButton update="matchGrid" value="Save" />  
    </p:panel>

Please see this link: http://www.primefaces.org/showcase-labs/ui/password.jsf . 请参阅此链接: http//www.primefaces.org/showcase-labs/ui/password.jsf Since you haven't specified you Primefaces version, I have to tell you that this solution is for Primefaces 3. 由于您尚未指定Primefaces版本,我必须告诉您此解决方案适用于Primefaces 3。

Try this code 试试这个代码

onkeyup="checkPass(this.value)" 

And javascript code: 和javascript代码:

function checkPass(text) {
  var pass1 = document.getElementById('password');
  if (text == pass1.value) {
    alert('match');
    return true;
  } else {
    return false;
  }
}

To get the string value we have to use following code in JSF Primefaces like, 要获取字符串值,我们必须使用JSF Primefaces中的代码,例如,

var pass1 = document.getElementById('password_input'); 
var pass2 = document.getElementById('confirmPassword_input'); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在java中检查密码是否是BCrypt编码的 - How to check whether a password is BCrypt encoded or not in java 如何检查在JSF或Primefaces中是否打开了浏览器窗口? - How to check whether a Browser Window is Opened or not in JSF or Primefaces? 检查密码/密钥是否匹配的方法 - method to check if password/keycode match 如何检查匹配的盐和哈希密码 - How to check match for salted and hashed password 在 Javascript 或 jQuery 中检查上传文件是否受密码保护 - Check uploading file is password protected or not in Javascript or jQuery 如何使用Java代码检查客户端浏览器中是否启用了JavaScript - How to check whether JavaScript is enabled in client browser using Java code 需要检查密码是否包含JAVA / ATG中用户名的相同字符序列 - Need to Check whether password contains same sequence of characters of UserName in JAVA/ATG 尝试将用户名和密码存储在数据库中并检查用户名和密码是否匹配以登录 - Trying to store username and password in a database and having it check if the username and password match to log in 检查作业是否正在运行? - Check whether the job is running or not? 检查证书是否有效 - Check whether the certificate is valid or not
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM