struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Siddiq Syed <>
Subject Re: s:textfield and date format as dd/MM/yyyy
Date Wed, 04 Nov 2009 19:08:26 GMT

But I guess there is no direct validation for a date in struts 2. 

If you give date validation like mention below

<field-validator type="date">
      <message>Joining date must be supplied between ${min} and

It will check for the range , not the validation , like invalid value and
leap year.

As far as what I saw is that reg expression will slove it easily but its not
readable and maintainable.

Greg Lindholm-2 wrote:
> <field-validator type="regex">
>> (((((((0[13578])|(1[02]))[\/]((0[1-9])|([12]\d)|(3[01])))|(((0[469])|(11))[\/]?((0[1-9])|([12]\d)|(30)))|((0?2)[\/]((0[1-9])|(1\d)|(2[0-8]))))[\/](((19)|([1-9][0-9]))([\d][\d]))))|((0?2)[\/](29)[\/](((19)|([1-9][0-9]))(([02468][048])|([13579][26])))))$
>> </field-validator>
> IMHO this is unreadable and unmaintainable and should never be used (even
> if
> it does work).
> You would be better off changing your 'date' property to be a String and
> handle validation in a validate() method using a DateFormat object.

View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message