- <P><head>
- <title>表单注册</title>
- <style type="text/css">
- table{
- border:#0066ff 1px solid;
- width:500px;
- border-collapse:collapse;
- }
- table td,table th{
- padding:2px;
- }
- .errorinfo{
- color:#ff0000;
- display:none;
- }
- </style>
- <script type="text/javascript">
- //校验性别是否填写
- function checkSex(){
- var temp=false;
- var xbObj1=document.getElementById("nan");
- var xbObj2=document.getElementById("nv");
- if(xbObj1.checked || xbObj2.checked){
- temp=true;
- }
- return temp;
- }
- function checkform(sexNode){
- var divNode=document.getElementById("sexdiv");
- if(!checkSex()){
- sexNode.className="error";
- divNode.style.display="block";
- return false;
- }
- else{
- sexNode.className="norm";
- divNode.style.display="none";
- }
- }
- </script>
- </head>
- <body>
- <form>
- <table>
- <tr>
- <th>注册表单</th>
- </tr></P>
- <P>
- tr>
- <th>
- <div>
- 性别:<input type="radio" name="sex" id="nan" onblur="checkform(this)"/>男
- <input type="radio" name="sex" id="nv" onblur="checkform(this)"/>女
- </div>
- <div class="errorinfo" id="sexdiv">必填</div>
- </th>
- </tr></P>
- <P>
- <tr>
- <th>
- <div>
- 城市:<select name="country" onblur="checkCounty(this)">
- <option value="none">--选择省份--</option>
- <option value="hainan">海南省</option>
- <option value="guangdong">广东省</option>
- <option value="hunan">湖南省</option>
- <option value="other">其他</option>
- </select>
- </div>
- <div class="errorinfo" id="countydiv">必填</div>
- </th>
- </tr>
- <tr>
- <th>
- <div>兴趣爱好</div>
- <div><input type="checkbox" name="interests" value="basketball"/>篮球
- <input type="checkbox" name="interests" value="football"/>足球
- <input type="checkbox" name="interests" value="music"/>音乐
- <input type="checkbox" name="interests" value="film"/>电影
- <input type="checkbox" name="interests" value="others"/>其他</div>
- <div class="errorinfo" id="interestsdiv">必填</div>
- </th>
- </tr>
- </table>
- </form>
- </body></P>
复制代码 |
|