I m using a rich:calendar to display Date in my application But some how date validation isn't working properly in a part开发者_JAVA百科icular scenario. i.e it some one enters date as 05/05/2010sfc in this case it automatically trims the extra characters in the end and displays date properly in next page instead of giving an error of invalid date on same page.
It works in other cases such as asd05/05/2010, 05sfa/05/2010, etc
I tried using but it didn't help
Can anyone please help me on this...
I used this tag to restrict the length to 10 characters:
< rich:calendar value="#{myBean.date}"datePattern="MM/dd/yyyy" enableManualInput="true" inputStyle="width:80px">
< f:attribute name="maxlength" value="10"/>
< /rich:calendar>
That's indeed how SimpleDateFormat
(which it is using under the hoods) by default works.
Best what you can do is to restrict the input field max length to 10 or supply a custom date validator.
精彩评论