LotusScript Form Validation Code
This code will validate the specified fields and return a single message box listing all the fields that do not meet the validation requirements. This works great in form submit buttons where other code needs to be executed that can't normally be done using formula language.
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim msg As String
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
'Replace FieldNameX with your field names.
msg = ""
If doc.FieldName1(0) = "" Then
msg = "Text description of FieldName1" & Chr(13)
End If
If doc.FieldName2(0) = "" Then
msg = msg & "Text description of FieldName2" & Chr(13)
End If
If doc.FieldName3(0) = "" Then
msg = msg & "Text description of FieldName3" & Chr(13)
End If
'Continue for for all fields that require validation.
If msg <> "" Then
MsgBox msg,0+64,"The following fields were left blank or contain incorrect values..."
Exit Sub
End If
'Enter more code here if needed.
Call doc.Save(True,True)
Call uidoc.Save
Call uidoc.Close