xiaodao
03-22-2009, 11:14 AM
Hi
Sorry , need a hint on validating checkbox , make sure at least one checkbox is checked.
<form onClick="return formcheck()" name="checkform">
<input type="checkbox" name="haha[]" value="lala">
<input type="checkbox" name="haha[]" value="yoyo">
<input type="submit" name="submit" value="submit">
</form>
so what i should write this formcheck function
function formcheck() {
if (document.checkform.getElements['checkbox'].checked== false){
alert ('You didn\'t choose any of the checkboxes!');
return false;
}else{
return true;
}
}
is this correct?
Sorry , need a hint on validating checkbox , make sure at least one checkbox is checked.
<form onClick="return formcheck()" name="checkform">
<input type="checkbox" name="haha[]" value="lala">
<input type="checkbox" name="haha[]" value="yoyo">
<input type="submit" name="submit" value="submit">
</form>
so what i should write this formcheck function
function formcheck() {
if (document.checkform.getElements['checkbox'].checked== false){
alert ('You didn\'t choose any of the checkboxes!');
return false;
}else{
return true;
}
}
is this correct?