Examples: IsValidDate property

This exiting script checks the string testdate which the user entered in the Date/Time field dtField. Testdate is used to create the new NotesDateTime object dt. The date is automatically converted to the string found in dt.LocalTime. If it is not a valid date, a message box tells the user to enter a new date.

Sub Exiting(Source As Field)
  Dim workspace As New NotesUIWorkspace
  Dim uidoc As NotesUIDocument
  Dim testdate As String
  Set uidoc = workspace.CurrentDocument
  testdate = uidoc.FieldGetText ( "dtField")
  Dim dt As New NotesDateTime(testdate)
  If Not dt.IsValidDate Then 
    Messagebox "Please enter a new date." , , "Invalid date"
    Call uidoc.GotoField ( "dtField")
  End If
End Sub