javaScript实现简单的表单验证
来源:互联网 发布:酒鬼蔷薇圣斗 知乎 编辑:程序博客网 时间:2024/06/08 17:55
<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>验证注册页面</title><style type="text/css">body{lmargin:0; padding:0;}.p1{font-size:12px; text-align:right; height:28px; width:80px;}input{font-size:12px; border:solid 1px #61b16a ; width:150px; height:20px;}.submit{ font-size:12px; background-color:#eeeeee; border:solid 1px #cccccc ; width:60px; height:23px; padding-top:3px; }textarea{ font-size:12px; border:solid 1px #61b16a ; }#mytable{ margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; width:760px; }#main{border-left:solid 1px #7bcc87; border-right:solid 1px #7bcc87; background-color:#f9f8ff; }#center{ margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; width:80%; }</style><script type="text/javascript"> function checkLoginUsername(){ var username = document.getElementById("username").value; if(username.length==0){ document.getElementById("usernameInfo").innerHTML="用户名不能为空!"; return false; } return true; } function checkLoginPwd(){ var pwd = document.getElementById("pwd").value; if(pwd.length==0){ document.getElementById("pwdInfo").innerHTML="密码不能为空!"; return false; } return true; } function checkLoginEmail(){ var email = document.getElementById("email").value; if(email.length==0){ document.getElementById("emailInfo").innerHTML="email不能为空!"; return false; } return true; } function checkForm(){ if(checkLoginUsername()&&checkLoginPwd()&&checkLoginEmail()){ return true; } return false; } function clearInfo(spanId){ document.getElementById(spanId).innerHTML=""; }</script></head><body><table id="mytable" border="0" cellspacing="0" cellpadding="0"> <form action="success.html" method="post" name="myform" onsubmit="return checkForm()"> <tr> <td><img src="images/reg-top.jpg"></td> </tr> <tr> <td id="main"><table id="center" border="0" cellspacing="0" cellpadding="0"> <tr><td class="p1"> 用户名:</td> <td> <input id="username" type="text" onfocus="clearInfo('usernameInfo')" onblur="checkLoginUsername()"/> <span id="usernameInfo" style="color:#F00"></span></td> </tr> <tr><td class="p1" > 密 码:</td> <td><input id="pwd" type="password" onfocus="clearInfo('pwdInfo')" onblur="checkLoginPwd()"> <span id="pwdInfo" style="color:#F00"></span></td> </tr> <tr><td class="p1" >E-mail:</td> <td><input id="email" type="text" onfocus="clearInfo('emailInfo')" onblur="checkLoginEmail()"> <span id="emailInfo" style="color:#F00"></span></td> </tr> <tr><td class="p1"> 个人简介:</td> <td><textarea id="intro" cols="30" rows="4"></textarea></td> </tr></table></td> </tr> <tr> <td background="images/reg-end.jpg" style="height:63px; text-align:center;"><input name="B1" type="submit" value="提交" class="submit"> <input name="B2" type="reset" value="重置"class="submit" > </td> </tr></form></table></body></html>
0 0
- 简单的表单验证代码javascript实现
- javaScript实现简单的表单验证
- 使用JavaScript实现表单的前端简单验证后提交
- javascript 基础 js实现简单表单验证
- JavaScript 简单表单验证
- javaScript--简单表单验证
- 一个简单的JavaScript表单验证框架
- javascript实现表单验证
- JAVAScript 中实现表单验证的函数
- JavaScript实现表单验证后的聚焦
- JS的实现简单的表单验证
- jquery实现简单的表单验证
- jquery实现简单的表单验证
- 用jQuery实现简单的表单验证
- javascript实现简单用户登录表单验证功能
- JavaScript实现简单表单验证-Web笔记(四)
- javascript脚本之表单验证(一些简单实用的javascript)
- javascript表单验证简单例子
- hdu 1869 六度分离(floyd)
- POJ 1988 Cube Stacking
- Spring容器注入bean
- poj 3641 Pseudoprime numbers
- [bzoj1812][ioi2005]riv(树上dp)
- javaScript实现简单的表单验证
- Android实现OCR扫描识别数字图片之图片扫描识别
- 在屏幕中显示单选框
- 利用泛型封装DAO层(万能DAO)
- HDC与CDC相互转换
- Java进阶(三十七)java 自动装箱与拆箱
- MFC之菜单资源详解
- 玩转Easy UI框架的artDialog(四)常用实例
- 1008. 数组元素循环右移问题 (20)