struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Siddiq Syed <siddiq...@yahoo.com>
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">
      01/01/1990
      01/01/2000
      <message>Joining date must be supplied between ${min} and
${max}</message>
    </field-validator>

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: http://old.nabble.com/s%3Atextfield-and-date-format-as-dd-MM-yyyy-tp26197512p26202747.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message