Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need a way to validate a date.
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00712402
Message ID:
00712537
Views:
9
* GRID Column 10 Text1 Valid Date
IF EMPTY(This.Value)
	DODEFAULT()
	RETURN .T.
ENDIF
IF SUBSTR(THIS.Value,1,2) $ "1920"
   DODEFAULT()
ELSE
    ThisForm.Message.Visible= .T.
    ThisForm.Message.Caption= "Invalid Century"
    CHRSAW(2.5)
    ThisForm.Message.Visible= .F.
    RETURN .F.
ENDIF
IF SUBSTR(THIS.Value,3,2) >"00"
   DODEFAULT()
ELSE
  ThisForm.Message.Visible= .T.
  ThisForm.Message.Caption= "Invalid Year"
  CHRSAW(2.5)
  ThisForm.Message.Visible= .F.
  RETURN .F.
ENDIF
IF SUBSTR(THIS.Value,5,2) >"00" AND SUBSTR(THIS.Value,5,2) <"13"
   DODEFAULT()
ELSE
  ThisForm.Message.Visible= .T.
  ThisForm.Message.Caption= "Invalid Month"
  CHRSAW(2.5)
  ThisForm.Message.Visible= .F.
  RETURN .F.
ENDIF
IF SUBSTR(THIS.Value,7,2) >"00" AND SUBSTR(THIS.Value,7,2)<"32"
   DODEFAULT()
ELSE
  ThisForm.Message.Visible= .T.
  ThisForm.Message.Caption= "Invalid Day"
  CHRSAW(2.5)
  ThisForm.Message.Visible= .F.
  RETURN .F.
ENDIF
This code from a grid column may give you an idea of what you want...

:~) Edgar

>Hi guys,
> I think I have a very complex way to do it. ctod() does not seem to generate any errors of the date is bad. I can emulate the date field with an input mask of '99/99/9999' and then do a ctod() on that. If it's blank then it is not a good date. There is only one problem, I can't update the value of the field as I skip though records. The control source has to be the field value. I could get around that with a functon in the refresh method but that means I would have to change about 140 or so text boxes in my program. The only way I can see to do it is to have my date text box class create a 2nd text box on top of itself with the chr type field as the control source. The valid would work in the 2nd text box and the 1st box could update the 2nd on each refresh. I hope someone can find a better way though. Thanks for your thoughts guys.
>
>John.
>
>>>
>>>I have a feeling John will be back on this thread <s>
>>
>>After re-reading, I would have to agree <s>
>>
>>Specially because CTOD() then will generate an error if a valid date was entered.
Edgar L. Bolton, B.S. B.B.A.
Previous
Reply
Map
View

Click here to load this message in the networking platform