Validating a date using Struts

Hoi all,

I am trying to validate a date in struts,

I have googled for a information and searched the forum but didn't find anything useful, I might have been asking the wrong questions.

I have set up my validate.xml and it captures a date that is like : aa/01/3000 and returns an error specifying that the date is wrong but when i type in 45/01/3000 the date is accepted as a valid date and I cannot understands why, the date validation is built in isn抰 it ?

Any help will be appreciated

[521 byte] By [Wernsa] at [2007-10-2 8:30:44]
# 1
http://struts.apache.org/struts-doc-1.2.4/userGuide/dev_validator.htmlThe date validation in Struts internally uses java.text.SimpleDateFormat. You will have to make the date pattern validation "strict". Refer to the documentation. :)
annie79a at 2007-7-16 22:31:40 > top of Java-index,Java Essentials,New To Java...
# 2
Thanks Annie Got is Sorted !
Wernsa at 2007-7-16 22:31:40 > top of Java-index,Java Essentials,New To Java...
# 3

Uhmmm i don抰 have it sorted.......

I have been trying to validate a specific date that info can be seen in my original post on top, This is what i have so far in my Validation.xml file

<form name="searchForm">

<field property="startDate" depends="date">

<arg0 >

<var><var-name>datePatternStrict</var-name><var-value>dd/MM/yyyy</var-value></var>

</field>

<field property="endDate" depends="date">

<var><var-name>datePatternStrict</var-name><var-value>dd/MM/yyyy</var-value></var>

</field>

<field property="endDate" depends="validwhenDate" >

<var>

<var-name>test</var-name>

<var-value>(startEndDateCompare!= -1)</var-value>

</var>

</field>

</form>

endDate and startDate are both strings and the startEndDateCompare is a method in the searchForm.java file that compares the parsed date values of the string dates of endDate and startDate via a simple date format, If this doesn抰 make sense let me know and I'll try to elaborate

now my questions is what am I doing wrong?

The validation still registers that 01/aa/3000 is an invalid date but not 45/01/3000 this is still validated as a correct date.

Thank for any help.

Wernsa at 2007-7-16 22:31:40 > top of Java-index,Java Essentials,New To Java...