Rao Archana (HCTM/ETA) wrote:
Hi,

I am working on date fields and have problems with the validation. I
have referred to the link below which helped me.

http://www.nabble.com/Strict-4-digit-year-for-DateTextField--td18656889.
html


So I have subclassed the PatternDateConverter and have set the pattern
as,
dateFormat = "^(\\d{1,2})/(\\d{1,2})/(\\d{4})$";

I have 2 date fields, start_date and end_date. The start_date is a
required field and the end_date is not.
(...)
This works fine ie it does not allow entry of "03/03/09" or
"03/03/-2009"

BUT, the end_date becomes a required field. I have to enter the end_date
to click 'Save'. Else it complains that an invalid date has been
entered.
But my end_date is not a required field.
(...)
Possibly the simplest approach would be to use a regular expression that allows an empty string like making the whole expression optional by surrounding it with paranthesis and adding the optional operator '?' after it. This allows the empty string OR a valid date but nothing else:
dateFormat = "^((\\d{1,2})/(\\d{1,2})/(\\d{4}))?$";

Matt

--
matthias.kel...@ergon.ch  +41 44 268 83 98
Ergon Informatik AG, Kleinstrasse 15, CH-8008 Zürich
http://www.ergon.ch
______________________________________________________________
e r g o n    smart people - smart software


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to