jsf - Validate regex for PrimeFaces Password -


i have password , repeat password fields,but want validate passwords depending on validate regex pattern along matching both password fields too.

           <p:outputlabel for="password" value="password" />                 <p:password id="password" redisplay="true"                     value="#{newuserbean.newuserdto.password}" match="repeatpassword"                     label="password" required="true"                     requiredmessage="password required, cannot empty"                     validatormessage="password , repeat password fields must same" feedback="true"                     promptlabel="password should contain atleast 8 characters ,1 number , 1 special character" >                 </p:password>                 <p:outputlabel for="repeatpassword" value="repeat password" />                 <p:password id="repeatpassword" redisplay="true"                     value="#{newuserbean.newuserdto.password}" label="repeatpassword"                     required="true"                     requiredmessage="password required, cannot empty" feedback="true"                     promptlabel="repeat password should match password">                 </p:password> 

make changes below

<p:outputlabel for="password" value="password" />                 <p:password id="password" redisplay="true"                     value="#{newuserbean.newuserdto.password}"validator="#{passwordvalidator.validate}"                     label="password" required="true"                     requiredmessage="password required, cannot empty"                     validatormessage="password , repeat password fields must same" feedback="true"                     promptlabel="password should contain atleast 8 characters ,1 number , 1 special character" > <p:ajax event="blur" update="msgfrpassword" />                 </p:password>                 <p:outputlabel for="repeatpassword" value="repeat password" />                 <p:password id="repeatpassword" redisplay="true"                     value="#{newuserbean.newuserdto.password}" label="repeatpassword" validator="#{confirmpasswordvalidator.validate}"                     required="true"                     requiredmessage="password required, cannot empty" feedback="true"                     promptlabel="repeat password should match password"> <p:ajax event="blur" update="msgfrpassword" />                 </p:password> 

override java validator verify regex , compare repeat password , password

passwordvalidatorbean

@override     public void validate(facescontext context, uicomponent component,             object value) throws validatorexception {         matcher = pattern.matcher(value.tostring());         if (!matcher.matches()) {              facesmessage msg = new facesmessage(                     new messageprovider()                             .getvalue("prometheus_passwordpromptlable"));             msg.setseverity(facesmessage.severity_error);             throw new validatorexception(msg);          }      } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -