Lotus Notes FAQ Visit Our Sponsor!

How do you validate and jump to fields which have validation errors?

This example will check that all required fields are filled in. If a field is not filled in, it will move the cursor in the web browser to that field.

Put this in the onClick JavaScript event of your submit button:


Place in Form

function DocumentSave()  {
  fieldList = new MakeArray(2);  //set array for how many fields to check
  fieldList[1] = document.forms[0].f_ORG_UnitName;
  fieldList[2] = document.forms[0].f_ORG_UnitAbbreviation;
  DocumentOK = FieldValidation(fieldList);
  if (DocumentOK)

Place in Subform (Generic Sub-form)

// By James Fox@Com Tech
//This function will return the length of an array
function ArrayLength(obj) {
  var result = -1;
  for (var i in obj)
    result += 1;
  return result;

//This function will perform field validation on the current Lotus Notes document
// for all fields in the fieldsToCheck array.
function FieldValidation(fieldsToCheck){
  var continueFlag = true;
  for (var i=1; i <= ArrayLength(fieldsToCheck);i++) { 
    if (fieldsToCheck[i].value == "") {
      alert("Please ensure you enter a value for all fields marked with a Star.");
      continueFlag = false;
  if (continueFlag) 
    return true;  

Applies to Notes Versions: 4, 4.5, 4.6, 5
Last Modified: September 8, 1999