Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dates before 1900
Message
From
28/05/1999 13:36:02
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00223881
Message ID:
00224000
Views:
19
>>>Hello:
>>>
>>>I'm trying to force users not to enter dates before 1900 into a text box.
>>>
>>>I have the following code in the valid event but it won't allow
>>>me to enter any dates now. Dates entered, i,.e. 1965/09/08 give me invalid input.
>>>
>>>Local llpastdate
>>>llpastdate = this.value < {1900/01/01}
>>>
>>>
>>>
>>>If llpastdate
>>>=messagebox("You cannot enter a century befpre 1900")
>>>Endif
>>>return llpastdate
>>Hi Sheena,
>>First prefer lostfocus for validation (valid is more problematic).
>>Dateformat might not be in YYYYMMDD thus returning an emptydate better use strictdate formats and expressions as {^1900/01/01}.
>>Return dDate in valid is not a valid option. Return num or logical expression.
>>If you need to check only dates are not before 1900 then use year() to check.
>>
* lostfocus
>>if year(this.value) < 1900
>>* Is empty(date) allowable ? - If so add "and !empty(this.value)"
>> nodefault   && Prevent focus to change
>> messagebox("You cannot enter a century before 1900")
>>endif
>
>Hi Cetin,
>
>I'll have to disagree about putting this in LostFocus. Under some circumstances, it is possible for this to be bypassed. For example, assume that there's a command button that closes the form. If the user clicks on it and there's an invalid entry in the text box, the form closes. However, if this code is in the Valid, the user cannot click the command button.

Yes, not a commandbutton but a toolbar might let it. OTOH valid is easily defeated when it's on a grid too. I prefer lostfocus because you can call other things easily ie: setfocus().
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform