我正在使用PrimeFaces。当用户按下" save"时,输入将被验证。按钮,但我需要在用户清除输入字段时动态清除错误消息。
<div class="item">
<p:outputLabel for="firstName" value="#{msgs['customerForm.firstName']}"/>
<p:inputText id="firstName" value="#{customerBean.customer.firstName}"
requiredMessage="#{msgs['Error.firstName.mandatory']}"
required="true"
validatorMessage="#{msgs['Error.firstName.wrongFormat']}">
<f:ajax execute="@this" event="keyup" render="m_zeroField"/>
<f:validateRegex pattern="^([a-zA-Z]+[a-zA-Z\s\-]*)?$"/>
</p:inputText>
<p:message id="m_firstName" for="firstName" display="text"/>
<p:message id="m_zeroField" for="firstName" display="text" rendered="#{customerBean.customer.firstName.isEmpty()}"/>
</div>