Trap needed for properly entered date

Has anyone come up with a method for trapping that a user has entered a date properly (ie desired format = M/d/yyyy, entered date = 3/15/2006 and not 3/15/06)? I would like to prevent my users from seeing the “Cannot save form data” error that occurs when they have entered an improper date. They don’t seem to understand what the red text means.

Thanks in advance,
Steve in LA

I think this might be what you are looking for…

http://www.servoymagazine.com/home/2005 … ng_fo.html

That’s close, but it has a few problems. Assigning the described method to the onFocusLost event checks whether the value of the dataprovider evaluates as null and if so, doesn’t let the user do anything until a valid date is entered. What if the user is tabbing through the form and intends to leave this field blank?

Also, the trap for the 2-digit year does not work properly for me. If a user enters 3/15/06, the date is changed to 3/15/0006 and when focus is lost, I get this error:

Cannot save form data
Details>> java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]The year, 6, is outside the range allowed by the SQL Server.

I checked my SQL server settings and the Two Digit Year Support range is set to 1950 to 2049, which makes sense. I assume it is Servoy that is adding the ‘00’ then. Is there some way to control Servoy’s Two Digit Year Support?
WORKAROUND: If I change the default date format in preferences to ‘M/d/yy’, and make the Format property of the date field ‘M/d/yyyy|M/d/yy’, when a user enters a 2-digit year <= 26, it is changed to 20 + 2-digits (2026) and 19 + 2-digits if 2-digit year > 26 (1927), so I guess that works. Oddly enough, for my current application, many entered dates will be prior to 1927, but I think if a user sees the date change from 26 to 2026, it will be a big enough hint.

Steve in LA

Why don’t you use the format property. The Mask will prevent the user from entering the wrong format… A null/empty value is consired a correct format in such case…

I am using the format property, but it doesn’t exactly prevent the user from entering bad data. It just prevents bad data from being saved to the database, and gives a “Cannot save form data” error when the bad data attempts to save. That is the behavior I am trying to side-step.

Steve in LA