Domino Code Fragment

Code Name*
How do you validate and jump to fields which have validation errors?
Date*
07/08/2000
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.
Description*
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.
Type*
JavaScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:

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

javascript:DocumentSave();

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)
document.forms[0].submit();
}


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 Botes 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;
  fieldsToCheck[i].focus();
  break;  
 }  
}
if (continueFlag)
 return true;  
}