jsf - How to print javascript alert message in p:message of primefaces -
javascript of code
function checkpasswordmatch() { var password = document.getelementbyid("password").value; var confirmpassword = document.getelementbyid("confirmpassword").value; if (password != confirmpassword){ alert("passwords not match!"); }else{ alert("passwords match."); } }
primefaces jsf code
<h:form> <h:panelgrid columns="2" id="matchgrid" cellpadding="5"> <h:outputlabel for="pwd1" value="password 1: *" /> <p:password id="pwd1" value="password" label="password" required="true" /> <p:message for="pwd1"/> <h:outputlabel for="pwd2" value="password 2: *" /> <p:password id="pwd2" value="confirmpassword" onkeyup ="checkpasswordmatch();" label="confirm password" required="true" /> <p:message for="pwd2"/> </h:panelgrid> <p:commandbutton update="matchgrid" value="save" /> </h:form>
i want print alert message in p:message.. possible so..?? please help
you have use primefaces user guide tells you. first p:password
component must have match
attribute, not second.
if second p:password
component has match
defined following happens. when validating first p:password
submitted value deemed valid (which wrong in itself), gets set null, , local value set. p:password
match validation works comparing submitted values. when validating second p:password
thinks first component not filled @ all, , declares mismatch.
more on local , submitted values here.
Comments
Post a Comment