I am using PrimeFaces. The Input is validated when the user presses the "save" button, but I need to clear the error messages dynamically when the user clears the input field.
<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>