没必要验证吧,给它一个默认值不就可以了。
--------------------------------------------------------------<FORM name="form1" action="register.asp" method=post>
<input type="radio" name="a" value="d" checked>
<input type="radio" name="a" value="c">
<input type="submit" name="Submit" value="sub">
</form>
--------------------------------------------------------------<FORM name="form1" action="register.asp" method=post>
<input type="radio" name="a" value="d" checked>
<input type="radio" name="a" value="c">
<input type="submit" name="Submit" value="sub">
</form>
/**
*get the value of a group of radiobox
*@param radioBox the object of radioBox
*@return the value of the radioBox checked or false for none checked
*@example var value = getRadioValue(this.form1.radioGroup);
*/
function getRadioValue(radioBox){
try{
if(radioBox == null){
return false;
}
var length = radioBox.length;
if(length == null){
if(radioBox.checked)
return radioBox.value;
else
return false;
}else{
for(i = 0; i < length; i++) {
if(radioBox[i].checked)
return radioBox[i].value;
}
return false;
}
}catch(e) {
return false;
}
} function FormCheck(){
if(!getRadioValue(document.form1.a)){
alert("222");
return false;
}
}</script>