Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Avoid "Invalid date" message
Message
From
24/01/2005 15:54:37
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00825981
Message ID:
00980186
Views:
37
>>
>>*** Keypress event
>>LPARAMETERS nKeyCode, nShiftAltCtrl
>>
>>If inlist( nKeyCode, 9, 13, 15 ) and empty( This.Value ) and !empty(left( This.Text, 2 ))
>>	MessageBox( 'You are entering an invalid date', 16, ' MyApplication' )
>>	This.Value = {}
>>	NoDefault
>>endif
>>
>>
>>HTH
>
>Thanks, Herman. Judging by the code only (I'm running data update now, so can not test), I believe, this code doesn't cover all invalid cases. What if the user enters only month portion of the date and leaves date portion empty?

It still works. The key here is, VFP will filled in TextBox.Value only *if* the date is valid. So we can validate it using Textbox.Text property. And that's the reason why I only checked for 2 characters from the left

Using the code I posted, it will throw the usual VFP message "invalid date" only if the user type in an invalid date then click some object (using mouse). You will have to add your additional check for this
Herman
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform