JavaScript: checking for at least item on survey completed

http://www.webxpertz.net/forums/printthread.php?t=31724
function
checkOne(frm
){
  var
oneFilled = false
;
  for(var
i = 0;i < frm.elements.length;i
++){
    switch(
frm.elements[i].type
){
      case
"text": oneFilled = frm.elements[i].value.length > 0
;break;
      case
"radio"
:;
      case
"checkbox":oneFilled = frm.elements[i].checked
;break;
      case
"textArea":oneFilled = frm.elements[i].value.length > 0
;break;
      case
"select":oneFilled = frm.elements[i].selectedIndex > -1
;break;
    }
    if(
oneFilled
) break;
  }
  return
oneFilled
;
}

你可能感兴趣的:(JavaScript)