Validate checkbox

I adverntyly sent the wrong script with the last post.I am new to JavaScript and need some help. I am using some script that I got off this forum. The following is supposed to validate a checkbox. I have this in a page with the js extension.

function validateTreatment(fld, errMsg)

{

for (index = 0; index < fld.length; index++)

{

	if (certs[index].checked)

		return true;

}

alert("Please select at least one choice for " + errMsg + ".");

fld[0].focus();

return false;

}//endfunction validateTreatment

I have the following as part of my function in the js header

else if (validateTreatment(f.txtConsult, ‘Please Enter a Treatment’) == false)

return false;

I get the following error. Certs undefined. I am not sure what certs is doing. Should it be declared? Thanks for your help.

function validatePCP(fld, errMsg)

{

if(fld.value==“”)

{

alert("Please enter a value for " + errMsg + “.”);

return false;

}//endif

return true;

}//endfunction validatePCP

Subject: validate checkbox

use

(fld[index].checked)

in place of

(certs[index].checked)

This should eliminate your JavaScript error as it will use the field you pass into the function.

Subject: More information

Suggest you put your validation function in the JSHeader event of the Notes form:

function validateTreatment(fld, errMsg)

{

for (index = 0; index < fld.length; index++)

{

if (fld[index].checked)

return true;

}

alert(errMsg);

fld[0].focus();

return false;

}

And you call the validation function in the onSubmit event of the Notes form:

return validateTreatment(forms[0].ddd, ‘Select one or more choices’)

In this example, ddd is the name of the checkbox field on the Notes form.