Date Validation
1 posts in topic
Flat View  Flat View

Posted By:   James_Scrimshire
Posted On:   Tuesday, February 17, 2004 01:32 AM

How can i configure the struts date validator, to check a date is valid. Not just its format, but the actual date

eg. 28/02/2004 is comes back fine using the SimpleDateFormat that i beleive struts uses.

But 31/02/2004 comes back as 02/03/2004

(date format is uk dd/MM/YYYY)

Obviously the 31st of feb doesnt exist, and i'd rather avoid the use of javascript checking. I currently have to handle this manually in the code and would prefer it if struts could do it for me.

any suggestions?

Re: Date Validation

Posted By:   Matan_Amir  
Posted On:   Tuesday, February 17, 2004 02:05 AM

Hi James,

Yes I had that problem once. I was using the Struts Validation engine as well. One solution is to create a new validator that takes a date format as a parameter. You can do that by creating the function, adding the definition to the validator-rules.xml file and use it in your validation.xml file with the parameter for the date format you are trying to check.

Hope that helps,

About | Sitemap | Contact