October 27, 2004

Fancy checkbox validation javascript

<!-- javascript function
function chx(myForm)
{
var sendit = false;
  for (var i=0;i < myForm.length;i++) {
    fldObj = myForm.elements[i];
    if (fldObj.type == 'checkbox') {
      if (fldObj.checked == true) {
        sendit = true;
      }
    }
  }
  if (sendit == true) {
    return true;
  } else {
    alert('Error Msg.');
    return false;
  }
}
--->

<!-- code for form -->
<form onSubmit="return chx(this);">

No comments: