专注于高品质PHP技术等信息服务于一体 [STIEMAP] [RSS]

百度提供的广告:
JSCSS
当前位置:首页 > 技术文档 > JSCSS >  > 
form 纯js 判断 radio 是否选择
<script type="text/javascript">
                    function check_form()
                    {
                        var temp_r_count=0;
                        for(var i = 0 ; i <document.personal.temp.length; i++)
                        {
                            if(document.personal.temp[i].checked)
                            {
                                temp_r_count++;
                            }
                        }
                        if(0==temp_r_count)
                        {
                            alert("你什么也没有选择");
                            return false;
                        }
                        
                    }
 </script>
<form onsubmit="return check_form()">
<input  type="radio" name="temp" > 男
<input  type="radio" name="temp" > 女
</form>
form 纯js 判断 radio 是否选择。