I got such kind of problem - I need to check in my JSF/PrimeFaces page if p:calendar
value (entered by user with keyboard) is empty and if it so to clear error message
this is my JSF Calendar snippet
<div class="item">
<p:outputLabel id="l_dateBirth" for="dateBirth" value="#{msgs['customerForm.dateBirth']}"/>
<p:calendar id="dateBirth" widgetVar="dateBirthVar" value="#{customerBean.customer.dateOfBirth}"
placeholder="MM/dd/yyyy"
showOn="button" navigator="true"
pattern="MM/dd/yyyy" yearRange="-120:+0"
mindate="#{dateBean.minDate}"
maxdate="#{dateBean.maxDateOfBirth}"
required="true"
requiredMessage="#{msgs['Error.dateBirth.mandatory']}"
disabled="#{customerBean.mode eq 'EDIT'}">
<f:ajax execute="@this" event="dateSelect" render="m_dateBirth" />
<p:ajax event="keyup" oncomplete="hideCustomerCalendarErrMsg('dateBirth')" />
<f:validator binding="#{dateOfBirthValidator}"/>
</p:calendar><p:message id="m_dateBirth" for="dateBirth" display="text"/>
</div>
this is my JS snippet
function hideCustomerCalendarErrMsg(variable) {
var inputField, msg;
inputField = PF('dateBirthVar').getDate();
msg = document.getElementById("createEditCustomerForm:accordion:m_" +variable);
if (inputField.value === null) {
msg.innerHTML = "";
}
}
so, please help me - it doesnt work. And I need to clear validator err message on the fly if user clear the field of calendar