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