Reputation: 365
In reference to this question,
it still accepts 8/1/201987
as a date, where in 201987
is not in yyyy
format.
How to ensure yyyy
format? Do I need to validate it in the bean?
I have used the code below :
<p:calendar ...>
<f:convertDateTime pattern="dd/MM/yyyy" />
</p:calendar>
But as it uses SimpleDateFormat
, if you give yyyy
it accepts any number of digits.
How to resolve this issue?
Upvotes: 3
Views: 10472
Reputation: 354
Try mask for p:calender like mask="99/99/9999", it's works fine for me
<p:calendar value="8/1/201989" mask="99/99/9999">
<f:convertDateTime pattern="dd/MM/yyyy" />
</p:calendar>
Upvotes: 1
Reputation: 142
You can restrict the user input by adding attributes mask="true" and maxlength=10
Upvotes: 0