html第六课时js基础
来源:互联网 发布:云计算saas 编辑:程序博客网 时间:2024/05/09 02:11
<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8"> <title></title> <script type="text/javascript">//js的样式开头必须是这样的。 function validate()//他的方法必须以function开头。 { var staffNo=document.getElementById('staffNo'); var staffName=document.getElementById('staffName'); var sex=document.getElementsByName('Sex'); var pos=document.getElementById('pos'); var password=document.getElementById('password'); var introduction=document.getElementById('introduction'); if(staffNo.value=="") { alert("员工工号不能为空!"); staffNo.focus(); return false; } if(staffName.value=="") { alert("员工姓名不能为空!"); staffName.focus(); return false; } if(sex[0].checked)//checkbox的验证是否为空的方法 { console.log("您选择了男","提示") /*alert(sex[0].value);*/ } else { console.log("您选择了女","提示") /*alert(sex[1].value);*/ } /*var index=pos.selectedIndex; var posvalue=pos.options[index].text;*/ if(pos.value=="") { alert("请选择职位!"); pos.focus(); return false; } if(introduction.value=="") { alert("请输入简介!"); introduction.focus(); return false; } /*string.prototype.trim=function() { return this.replace(/(^\s*)|(\s*S)/g,""); 正则表达式 }*/ return true; } </script></head><body><form action="" method="post"> <table border="1" align="center" bordercolor="#ccc" cellpadding="5px"> <tr align="center"> <td colspan="3" > 员工信息 </td> </tr> <tr > <td align="center" width="20%" > 工号: </td> <td width="50%" align="left" > <input name="staffNo" id="staffNo" class="input">//添加Id唯一标识 </td> <td width="30%" rowspan="5"> <img width="100%" id="image" height="300px" src="images/1.jpg"> </td> </tr> <tr > <td> 姓名: </td> <td align="left" > <input name="staffName" id="staffName" class="input"> </td> </tr> <tr > <td> 性别: </td> <td align="left"> <input type="radio" name="Sex" value="Man" checked>男 <input type="radio" name="Sex" value="Woman">女 </td> </tr> <tr > <td > 照片: </td> <td align="left" > <input type="file" id="photo" name="staffPic"> </td> </tr> <tr > <td> 职位: </td> <td align="left"> <select name="pos" id="pos"> <option value=""> 请选择职位 </option> <option value="1002"> 医生 </option> <option value="1002"> 护士 </option> </select> </td> </tr> <tr > <td> 密码: </td> <td colspan="2" align="left"> <input type="password" id="password" name="password" class="input"> </td> </tr> <tr class="tr"> <td> 简介: </td> <td colspan="2" align="left"> <textarea cols="80" rows="8" id="introduction"></textarea> </td> </tr> <tr > <td colspan="3"> <input type="submit" onclick="return validate()" value="提交"> <input type="reset" value="重置"> </td> </tr> </table></form></body></html>
<pre name="code" class="html">table{ border-collapse: collapse; width: 60%; margin-top:8em; text-align:center;}tr{ height: 50px;}.tr{ height:100px;}.input{ width:200px; height:22px;}select{ width:80px; height:22px;}textarea{ text-indent:2em;}
0 0
- html第六课时js基础
- html第九课时,js显示helloworld
- html第九课时,js使用方式1.行内js
- HTML基础第六讲---表格
- java----继承(第六课时)
- HTML5第六课时,后代继承
- HTML5第六课时,后代选择器
- HTML5第六课时,padding内边距
- HTML5第六课时,盒子弧度
- html第一第二课时
- html第三课时
- html第四课时
- html第十六课时汇总
- html/css_1基础【HTML/JS】
- HTML---第六章盒子模型基础
- HTML基础之JS
- Java基础课时1
- H5基础第一课时
- Robotium学习笔记一
- android内核处理机制
- 【JAVA】接口与抽象类
- Reverse Linked List II
- i++分析
- html第六课时js基础
- 堆排序
- 杭电 2060
- HDU 2159FATE(二维背包)
- C++中析构函数为什么是虚函数
- CCTableView源码分析
- “强制网络门户”技术
- Lua语言学习之模块与包
- django模版路径问题