You're right. RE is not suitable in this case.
 
If we don't specify a pattern, Struts will use SimpleDateFormat's default which 
is MM/dd/yyyy (I've just read about it in the Struts In Action book from 
somebody here last week, so I'm not sure if that pattern is the default). One 
thing I'm sure of is that Struts will not try more than one date format rule.

>>> [EMAIL PROTECTED] 8/15/2005 1:41:02 PM >>>

Thai Dang Vu wrote:
> If I want to validate a date field, I will put something like this in the 
> validation.xml file
>  
> <field property="myDate" depends="date">
>     <arg0 key="Date field" resource="false"/>
>     <var>
>         <var-name>datePattern</var-name>
>         <var-value>MM/dd/yyyy</var-value>
>     </var>
> </field>
>  
> So, if I want to enable 2 ways of entering a date (MM/dd/yyy and MM-dd-yyyy), 
> how should I write in the validation.xml file?

The only two possibilities I can think of are to use the match validation 
with a suitable regular expression, which will allow you to make sure the 
date string is in the right format but can't easily check that it's really 
a legal date, or write your own custom validation rule. The date validation 
doesn't provide for specifying multiple patterns.

Actually, one other possibility: if you don't specify a pattern, Validator 
will use SimpleDateFormat's default short date format rules, which might be 
more flexible than you can express with a pattern; check the documentation 
for SimpleDateFormat to see if that would meet your needs.

L.
-- 
Laurie Harper
Open Source advocate, Java geek: http://www.holoweb.net/laurie 
Founder, Zotech Software: http://www.zotechsoftware.com/ 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to