Reputation:
Ok so i have a calendar field:
<p:calendar id="dateOfBirth" mode="popup" placeholder="Date Of Birth" navigator="true" yearRange="c-18:c" pattern="dd.MM.yyyy"/>
And in javascript i want to check if the field has been entered a date:
if($("#dateOfBirth").val() === ""){
errors.push("dateOfBirth");
}
But it is not working. How can i make this equality in order to check that the user has skipped the field without entering anything?
Upvotes: 0
Views: 309
Reputation: 4841
p:calendar
renders not just as a HTML input
element. But it contains an input
element which has the id you specified plus a postfix, which is _input
. So your code should work if you change it to the following
if($("#dateOfBirth_input").val() === ""){
errors.push("dateOfBirth");
}
Upvotes: 0