Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
lcDate = '{'+thisform.text1.value+'}'
if TYPE(lcDate) = 'D'
... The date is valid
lcInput = thisform.text1.value
lcDate = '{^ '+ SUBSTR(lcInput,7,4) ;
+'/' + SUBSTR(lcInput,1,2) ;
+'/' + SUBSTR(lcInput,4,2)
if TYPE(lcDate) = 'D'
... The date is valid
PUBLIC oForm
oForm = CREATEOBJECT("clsValidateDates")
oForm.show()
DEFINE CLASS clsvalidatedates AS form
Top = 0
Left = 0
Height = 250
Width = 399
DoCreate = .T.
Caption = "Validate Dates"
Name = "Form1"
AutoCenter = .T.
ADD OBJECT text1 AS textbox WITH ;
Alignment = 3, ;
Value = {}, ;
Height = 23, ;
Left = 48, ;
Top = 69, ;
Width = 100, ;
Name = "Text1"
ADD OBJECT text2 AS textbox WITH ;
Height = 23, ;
Left = 48, ;
Top = 192, ;
Width = 100, ;
Name = "Text2"
ADD OBJECT label1 AS label WITH ;
WordWrap = .T., ;
BackStyle = 0, ;
Caption = "First textbox created with {} as it's value. VFP will handle validating the date, however we will override the 'Invalid Date' message to give the user more information.", ;
Height = 48, ;
Left = 48, ;
Top = 21, ;
Width = 312, ;
ForeColor = RGB(128,0,0), ;
Name = "Label1"
ADD OBJECT label2 AS label WITH ;
WordWrap = .T., ;
BackStyle = 0, ;
Caption = "Second textbox created without a default value, will allow the user to enter the date in a variety of ways. We will validate the user's entry in code by using the CTOD() function.", ;
Height = 48, ;
Left = 48, ;
Top = 144, ;
Width = 312, ;
ForeColor = RGB(128,0,0), ;
Name = "Label2"
PROCEDURE text1.LostFocus
ON READERROR
ENDPROC
PROCEDURE text1.GotFocus
ON READERROR Messagebox("The date you have entered is either" + CHR(13) + ;
"a bad date (such as 02/31/2004 or 01/00/2004)" + CHR(13) + ;
"or formatted incorrectly (enter dates as mm/dd/yyyy).",16,"Invalid Date")
ENDPROC
PROCEDURE text2.Valid
LOCAL ldDateEntered
IF !EMPTY(this.Value)
ldDateEntered = CTOD(this.Value)
IF EMPTY(ldDateEntered)
MESSAGEBOX("The date you have entered does not appear to be valid." + CHR(13) + ;
"Re-enter the date such as 01-31-2004 or 01/31/04.",16,"Invalid Date")
RETURN 0
ELSE
this.Value = DTOC(ldDateEntered)
ENDIF
ENDIF
ENDPROC
ENDDEFINE