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]

Reply via email to