Easy Password Confirmation

Password confirmation is a common case and PrimeFaces has a simple feature to make it easy for page authors.

<h:outputLabel for="pwd1" value="Password 1: *" />
<p:password id="pwd1" value="#{passwordBean.password6}" feedback="false" 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"/>

The match attribute does the trick, if the two inputs are not same, a validation exception is thrown;

11 thoughts on “Easy Password Confirmation

  1. Perfect!
    Cagatay, could you remind, how have you managed to create red borders in cases of validation error? Is this the built-in PF functionality or you used JSF component listeners as you did for labels?


  2. Anton, red borders came from theme aware .ui-state-error style class which almost all PrimeFaces input components apply to themselves when they are invalid so it is built-in feature of PF.