JS Validation not working from action bar button

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;

}

}

}

Subject: RE: JS Validation not working from action bar button

It’s a waste of time for us to read through source code for your error when you could just open the Javascript console and see what error it’s printing, with line number.

Subject: Do-It-Yourself JavaScript Debugging

Dan,

I’m with Andre regarding helping you be self-sufficient.

If you have the ability to use Firefox, I’ve heard great things about the Firebug JavaScript debugger plug-in.

If like me, you work for a company standardized on IE, then install Microsoft Script Debugger. This free download from Microsoft’s website is a godsend. It immediately locates the failing line of code. In IE Advanced settings, “Disable Script Debugging” should be UNCHECKED. Then whenever a JavaScript error is encountered, you will be prompted if you want to debug it. Click Yes.

Ken