DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>添加游戏title>
head>
<body>
<form action="" method="post" id="Game" onsubmit="return check()">
<table align="center">
<caption><h2>添加游戏h2>caption>
<tr>
<td>游戏名称:td>
<td><input type="text" id="Name" value="" />td>
tr>
<tr>
<td>开发商:td>
<td>
<input type="radio" name="firm" value="1" />九游
<input type="radio" name="firm" value="2" />腾讯
<input type="radio" name="firm" value="3" />暴龙
<input type="radio" name="firm" value="4" />暴雪
td>
tr>
<tr>
<td>添加你的真实年龄段:td>
<td id="age">
<input type="checkbox" value="0" />0-6岁<br />
<input type="checkbox" value="1" />6-12岁<br />
<input type="checkbox" value="2" />12-18岁<br />
<input type="checkbox" value="3" />18-30岁<br />
<input type="checkbox" value="4" />30岁以上
td>
tr>
<tr>
<td>游戏介绍:td>
<td><textarea id="Content" value="">textarea>td>
tr>
<tr>
<td>td>
<td>
<input type="button" value="提交" onclick="check()" />
<input type="button" value="重置" onclick="reset()" />
td>
tr>
table>
form>
body>
html>
<script>
var Name = document.getElementById("Name")
var Type = document.getElementById("Type")
var Checkbox = document.getElementById('age').getElementsByTagName('input')
var Content = document.getElementById("Content")
function check(){
if(!Name.value){
alert('请填写游戏名称');
return false;
}
if(!Type.value){
alert('请填写游戏类型');
return false;
}
for(var i=0;i<Checkbox.length;i++){
if(Checkbox[i].checked==true)
{break}
if(i==Checkbox.length-1){
alert('请选择你的真实年龄段');
return false;
}
}
if(!Content.value){
alert('游戏介绍');
return false;
}
}
function reset(){
Name.value = '';
Type.value = '';
for(var i=0;i<Checkbox.length;i++)
{Checkbox[i].checked==false}
Content.value = '';
}
script>
qq:2835809579