PreviousNext…

Tip #4: very simple rich text field validation

Background

If you search the good ole' LDD, you'll find there are stacks of ways to validate rich text fields, depending on what it is they will be storing, how flash you want to get, and so on.

Personally, I like this technique for when I don't need anything fancy… This code excerpt assumes your rich text field is called "Body", and that "uiDoc" is a NotesUIDocument (this code is typically run in / from a Querysave form event):

On Error Goto lblErrs

Call uiDoc.GotoField("Body")
Call uiDoc.SelectAll
Call uiDoc.DeselectAll

Exit Sub

lblErrs:
Messagebox "You have left the 'Body' field empty. This will not do!", 0, "Field Validation Failure"
Call uiDoc.GotoField("Body")
Exit Sub

BTW, for the geeks amongst you, the error number raised is "4407", so in your error handler you can trap for that specifically, and do something else if you like…

Comments

  1. Dose not work under if tab or spaces are entered…Lyndon#
  2. very simple rich text field validation.

    Duh#

Comments on this post are now closed.

About

I’m a software architect / developer / general IT wrangler specialising in web, mobile web and middleware using things like node.js, Java, C#, PHP, HTML5 and more.

Best described as a simpleton, but kindly. You can read more here.

";