Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Catching invalid date in text field?
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Catching invalid date in text field?
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01398647
Message ID:
01398647
Views:
109
I'm receiving a text field called ExportStartDate from a SQL Server stored procedure. It is defined as a varchar(10), the default value is blank. I'm putting in into a text field on the form and set the Format to D. I put the following code in the Valid hoping to catch if they entered a date incorrectly. My goal is only to have a valid date or an empty value. I thought the CTOD() function would throw an error if the date was invalid, but it simply returns a blank date. While a blank value is valid, it's not valid if they tried to enter a date.
LOCAL llerror 
IF !EMPTY(this.Value)
	ON ERROR llError=.t.
	mDate=CTOD(this.Value)
	ON ERROR DO errsys WITH ERROR(),MESSAGE(1),MESSAGE(),PROGRAM(), LINE(1)
	IF llerror=.t. 
		RETURN .f.
	ENDIF 
ENDIF 
Anyone have an idea how I should approach the validation of the data?

Thanks in advance

Kirk
Next
Reply
Map
View

Click here to load this message in the networking platform