【发布时间】:2017-06-27 15:30:28
【问题描述】:
我遇到了这样的问题 - 当用户通过 jsf 函数清除相关字段时,我试图在 jsf 页面上隐藏错误消息,但它不起作用
这是我调用 jsf 函数的 jsf 页面中的 sn-p
<div class="item">
<p:outputLabel for="phone" value="#{msgs['customerForm.phone']}"/>
<p:inputText id="phone" value="#{customerBean.customer.mobileNum}"
placeholder="380*********"required="true" requiredMessage="#{msgs['Error.phone.mandatory']}"
validatorMessage="#{msgs['Error.phone.wrongFormat']}">
<p:ajax event="keyup" oncomplete="hideCustomerErrMsg('phone')"/>
<f:validateRegex pattern="^380[\d]{9}$"/>
<f:ajax update="login"/>
<p:ajax event="change" update="login"/>
</p:inputText><p:message id="m_phone" for="phone" display="text"/>
</div>
这是我的 jsf 页面中的 sn-p - 当用户动态清除字段时我想隐藏的项目
<div class="errorMessages">
<h:outputText id="f_phone" value="#{msgs['Error.phone.duplicate']}" rendered="#{customerBean.mobileDuplicate}"
styleClass="ui-message-error"/>
<p:spacer width="20"/>
</div>
这是我的 js 函数
function hideCustomerErrMsg(variable) {
var inputField, msg, span;
inputField =document.getElementById("createEditCustomerForm:accordion:" + variable);
msg = document.getElementById("createEditCustomerForm:accordion:m_" + variable);
span = document.getElementById("createEditCustomerForm:f_" + variable).getElementsByTagName("span");
if (inputField.value === "" && msg.hasChildNodes()) {
msg.innerHTML = "";
span.innerHTML ="";
}}
【问题讨论】:
标签: javascript java jsf