自己写的js验证例子,不满足条件时会有文字提示的!不用alert!
来源:互联网 发布:windows安装nginx 编辑:程序博客网 时间:2024/06/08 00:31
<script type="text/javascript">
function check(obj){
if(obj.value.length < 6 || obj.value.length > 16) {
document.getElementById("errorinfo").style.display = "block";
document.getElementById("submit").disabled = true;
}
else {
document.getElementById("errorinfo").style.display = "none";
document.getElementById("submit").disabled = false;
}
}
function checkPwd(obj)
{
if (obj.value.length < 6 || obj.value.length > 16) {
document.getElementById("errorpwd").style.display = "block";
document.getElementById("submit").disabled = true;
}
else {
document.getElementById("errorpwd").style.display = "none";
document.getElementById("submit").disabled = false;
}
}
function checkRePwd(obj)
{
var p=document.getElementById("password");
if(obj.value.length<6||obj.value.length>16)
{
document.getElementById("errorrepwd1").style.display = "block";
document.getElementById("submit").disabled = true;
}
if (p.value != obj.value) {
document.getElementById("errorrepwd2").style.display = "block";
document.getElementById("submit").disabled = true;
}
else {
document.getElementById("errorrepwd1").style.display = "none";
document.getElementById("errorrepwd2").style.display = "none";
document.getElementById("submit").disabled = false;
}
}
function checkemail(obj)
{
var cEmail=obj.value;
if(cEmail.match(/[\w-]+@{1}[\w-]+\.{1}\w{2,4}(\.{0,1}\w{2}){0,1}/ig)!=cEmail){
document.getElementById("erroremail").style.display = "block";
document.getElementById("submit").disabled = true;
}
else{
document.getElementById("erroremail").style.display = "none";
document.getElementById("submit").disabled = false;
}
}
function checkqq(obj){
var q=obj.value;
var filter=/^\s*[.0-9]{5,10}\s*$/;
if(!filter.test(q)){
document.getElementById("errorqq").style.display = "block";
}else{
document.getElementById("errorqq").style.display = "none";
}
}
</script>
<link href="<%=request.getContextPath()%>/style.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#CCCCCC" >
<p style="color:#FF0000" align="center">温馨提示:带"*"为必填内容</p>
<form name="form1" method="post" action="servlet/RegisterServlet" >
<table width="41%" height="300" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr bgcolor="#FFFFFF">
<td height="27" colspan="2" align="center" background="images/table.gif"><strong><font color="#FFFFFF">欢迎加入</font></strong></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="19%" height="27" align="center">账号:</td>
<td width="81%" height="27"><input name="username" type="text" id="username" onblur="check(this)"/>
* <div style="display:none" id="errorinfo">账号长度必须在6至16个字符之间</div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="19%" height="27" align="center">密码:</td>
<td width="81%" height="27"><input name="password" type="password" id="password" onblur="checkPwd(this)"/>
* <div style="display:none" id="errorpwd">密码长度必须在6至16个字符之间</div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="19%" height="27" align="center">再次输入密码:</td>
<td width="81%" height="27"><input name="rePassword" type="password" id="rePassword" onblur="checkRePwd(this)" />
*
<div style="display:none" id="errorrepwd1">两次输入密码不一致</div>
<div style="display:none" id="errorrepwd2">密码长度必须在6至16个字符之间</div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="27" align="center">性别:</td>
<td height="27"><select name="sex" id="sex">
<option value="男" selected>男</option>
<option value="女">女</option>
</select></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="27" align="center">邮件:</td>
<td height="27"><input name="email" type="text" id="email" onblur="checkemail(this)"/>*
<div style="display:none" id="erroremail">输入邮箱格式有误</div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="31" align="center">QQ:</td>
<td height="31"><input name="qq" type="text" id="qq" onblur="checkqq(this)" />
<div style="display:none" id="errorqq">请输入正确的qq</div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="31" align="center">头象:</td>
<td height="31"><input name="tx" type="radio" value="images/face01.gif" checked>
<img src="<%=basePath%>images/face01.gif" width="32" height="32">
<input type="radio" name="tx" value="images/face02.gif">
<img src="<%=basePath%>images/face02.gif" width="32" height="32">
<input type="radio" name="tx" value="images/face03.gif">
<img src="<%=basePath%>images/face03.gif" width="32" height="32"> <br>
<input type="radio" name="tx" value="images/face04.gif">
<img src="<%=basePath%>images/face04.gif" width="32" height="32">
<input type="radio" name="tx" value="images/face05.gif">
<img src="<%=basePath%>images/face05.gif" width="32" height="32">
<input type="radio" name="tx" value="images/face06.gif">
<img src="<%=basePath%>images/face06.gif" width="32" height="32"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="31" colspan="2" align="center">
<input type="submit" value="提交" id="submit" style="width:50px" disabled="disabled"/>
<input style="width:50px;" type="reset" value="重置"/>
<input style="width:50px;" type="button" value="返回" onClick="window.location.href='http://localhost:8080/lastuse/servlet/QueryServlet'">
</td>
</tr>
</table>
</form>
- 自己写的js验证例子,不满足条件时会有文字提示的!不用alert!
- 自己写的条件渲染例子
- 自己写的js鼠标提示框
- 客户端基于层的验证不用alert方式
- 客户端基于层的验证不用alert方式
- 客户端基于层的验证不用alert方式
- 客户端基于层的验证不用alert方式
- 客户端基于层的验证不用alert方式
- 客户端基于层的验证不用alert方式
- 客户端基于层的验证不用alert方式
- 客户端基于层的验证不用alert方式
- 客户端基于层的验证不用alert方式
- 客户端基于层的验证不用alert方式
- 客户端基于层的验证不用alert方式
- 客户端基于层的验证不用alert方式
- 不用alert弹出窗口的方法来显示验证信息
- 删除 Map 中不满足条件的元素
- 练习五1002不满足条件的三位数
- Unity3d事件处理函数
- js网页时间字体解决方案
- wordpress自制留言板
- http://pkgs.org/search/?keyword=dmraid
- 委外加工
- 自己写的js验证例子,不满足条件时会有文字提示的!不用alert!
- 浅谈PDFlib中文输出(三)
- C#中怎么获取comboBox下拉列表选中项的Tag值
- 淺談PDFlib中文輸出(一)
- 搜索引擎优化的九大方法
- MySQL安装后出现“Error 1045(28000) Access Denied for user....."解决办法
- Linux端口以及防火墙端口的查看命令
- JAVA读文件方法大全
- 启动ssh服务时,提示Could not load host key: /etc/ssh/ssh_host_rsa_key