LotusScript Form Validation Code

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

    Requires Free Membership to View

    Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.

    By submitting your registration information to SearchDomino.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchDomino.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

This was first published in March 2001

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.