onkeyup="检查()";在 上显示输入元素值 null
在 primefaces 3.0.M3 中,使用 document.getElementById('confirmPassword') 将 textBox 值获取到 javaScript 时,会给出 null 值! 代码是: 在 primefaces 中:
<h:outputText value="Confirm Password*" />
<p:password
value="#{employeeRepositoryImpl.securityPrincipals.confirmPassword}"
required="true" label="Confirm Password" id="confirmPassword" for="confirmPassword" onkeyup="check()" >
update="confirmPassword" />
</p:password>
在 javaScript 中:
function check(){
var title1 = document.getElementById('confirmPassword');
var title2 = document.getElementById('password');
alert(title1+title2);}
我设置了 prependId="false" 。但警报显示为空。还有其他方法可以做到这一点吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您所提到的,生成的 HTML 如下所示,
这意味着表单仍会从中附加 id,请重新检查这些组件所在的
h:form
并设置prependId="false"
如果您尝试获取 ID 为
confirmPassword
的 HTML dom,它将返回null
,其中 HTML 中的实际 ID 为formId:confirmPassword_input
>As you mentioned, the HTML that is generated is as below
which means still form appends id from it, please recheck your
h:form
under which these components lies and set theprependId="false"
and if you try to get the HTML dom with id
confirmPassword
it will returnnull
where the actual ID in HTML isformId:confirmPassword_input