Hi all,
I have a web form that contains some fields that should be validated when the end-user clicks on a button. I have no idea why but I am gettig an error message in the Status Bar saying “Error on Page” when testing the button and the fields are empty. Can someone help me with this? What am I doing wrong here?
Thanks,
Dan
JS code in the onClick event of button:
// execute Tracking Grid validation code
return ValidateTrackingGrid();
JS code in the JSHeader event of form:
function ValidateTrackingGrid() {
selVal=“”;
doc=document.forms[0];
//===The input validation for the following fields is done when end-user clicks on the “Confirm Delivered to Customer and Completed” button
//===Radio button field
field=doc.DeliveredBy
readSelect(field);
if (selVal == “”) {
msg=“determine if this will be delivered by a staff member, IBC, or by Sprint Int’l.”;
alert("Please " + msg);
field.focus();
return false;
}
//===Dropdown field
oDeliveredBy=selVal;
field=doc.DeliveryEmpList
readSelect(field);
if ((selVal == “” || selVal == “-Select an Employee-”) && (oDeliveredBy==‘Staff Member’)) {
msg=“name of the employee who made the delivery”;
alert("Please select the " + msg);
field.focus();
return false;
}
//===Date field
oDeliveryEmpList=selVal;
field=doc.DeliveredDate
selVal=field.value;
if ((selVal == “”) && (oDeliveryEmpList==“-Select an Employee-” || oDeliveryEmpList == “”)) {
alert(“Please enter the Delivery Date” );
field.focus();
return false;
}
//===Text field
field=doc.ReceivedBy
selVal=field.value;
if (selVal == “”) {
alert(“Please enter the name of the recipient who signed for this WO.” );
field.focus();
return false;
}
//===Date field
field=doc.ReceivedDate
selVal=field.value;
if (selVal == “”) {
alert(“Please enter the Date that the recipient signed for this WO.” );
field.focus();
return false;
}
// end ValidateTrackingGrid
}
//===Radio button and dropdown/combobox type fields validation formula
function readSelect( field) {
sLen=field.options.length;
for(i=0;i<sLen;i++) {
if(field.options[i].selected) {
selVal = field.options[i].text;
}
}
}
//===Checkbox button validation formula
function readCheck(field ){
selVal=“”;
cbLen=field.length;
for (i =0; i < cbLen; i++) {
if (field[i].checked ) {
checkValue = field[i].value;
selVal=selVal+ " " + checkValue;
}
}
}