Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check whether password match or not in primefaces + javascript

How can I check whether password match or not in 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;"

like image 220
lofa in Avatar asked Feb 15 '26 06:02

lofa in


2 Answers

I don't understand why are you using Primefaces and not take advantage of it's power...

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:

<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 . Since you haven't specified you Primefaces version, I have to tell you that this solution is for Primefaces 3.

like image 73
spauny Avatar answered Feb 17 '26 19:02

spauny


To get the string value we have to use following code in JSF Primefaces like,

var pass1 = document.getElementById('password_input'); 
var pass2 = document.getElementById('confirmPassword_input'); 
like image 26
Nidheesh Avatar answered Feb 17 '26 18:02

Nidheesh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!