【发布时间】:2015-07-27 00:43:03
【问题描述】:
我的代码的Javascript
function checkPasswordMatch() {
var password = document.getElementById("password").value;
var confirmPassword = document.getElementById("confirmPassword").value;
if (password != confirmPassword){
alert("Passwords do not match!");
}else{
alert("Passwords match.");
}
}
primefaces jsf 代码
<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>
我想在 p:message 中打印警报消息.. 可以这样做..??请帮忙
【问题讨论】:
-
请在您的问题中更具描述性,这段代码中没有什么可看的......
-
嗨 Xtreme Biker.. 我想将我的代码更改为如下.. 但是当我输入密码和确认密码时.. 我仍然收到一条消息说密码不匹配.
-
@NewUser 您应该编辑您的问题。在评论中发布如此多的代码会使阅读变得非常困难。 ;)
-
发布的代码可以正常工作,即匹配的密码是否匹配?问题是,您想将
match属性移动到第二个p:password,但它不能正确匹配密码? -
我已经更新了代码和评论,谁能帮我解决这个问题。谢谢
标签: javascript jsf primefaces