求解jquery的表单验证写法
<!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=utf-8" />
<title>普通会员注册</title>
<link href="style/cont.css" rel="stylesheet" type="text/css" />
</head>
<script language="Javascript">
//表单校验
function strlength(str) {
var l = str.length;
var n = l;
for ( var i = 0; i < l; i++) {
if (str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255)
n++
}
return n;
}
function verify(memberform) {
var filter = /^\s*([A-Za-z0-9_-]+(\.\w+)*@(\w+\.)+\w{2,3})\s*$/;
if (!filter.test(document.memberform.email.value)) {
alert("邮箱不正确,请重新填写!");
document.memberform.email.focus();
document.memberform.email.select();
return false;
}
var filter = /^\s*[.A-Za-z0-9_-]{6,16}\s*$/;
if (!filter.test(document.memberform.password.value)) {
alert("密码填写不正确,请重新填写!可使用的字符为(A-Z a-z 0-9 _ - .)长度不小于6个字符,不超过16个字符,注意不要使用空格。");
document.memberform.password.focus();
document.memberform.password.select();
return false;
}
if (document.memberform.repassword.value != document.memberform.password.value) {
alert('重复密码错误');
return false;
}
if (document.memberform.username.value == "") {
alert('昵称不能为空');
document.memberform.username.focus();
document.memberform.username.select();
return false;
}
var checked = false;
var ids = document.getElementsByName("chick");
for ( var i = 0; i < ids.length; i++) {
if (ids[i].checked) {
checked = true;
}
}
if (!checked) {
alert("必须同意《 weok网路服务使用协议》 ");
return false;
}
return true;
}
String.prototype.Trim = function() {
var m = this.match(/^\s*(\S+(\s+\S+)*)\s*/);
return (m == null) ? "" : m[1];
}
</script>
<body>
<!--顶 部背景自适应开始-->
<div id="topbj">
<ul class="f12 clearfix">
<li>
欢迎访问weok网站!
</li>
<li>
<form action="hy_dl.jsp" method="post">
<input type="submit" value="登录" class="topbtn" />
</form>
</li>
<li class="zc">
<a href="hy_zc.jsp">注册</a>
</li>
<li class="bj2 sz">
<a href="mobile.jsp">手机版</a>
</li>
<li class="bj2">
<a href="fx.jsp">分享</a>
</li>
<li class="bj2">
<a href="shlb.jsp?t=2">商户</a>
</li>
<li class="bj2">
<a href="shlb.jsp?t=1">优惠活动</a>
</li>
<li class="bj2">
<a href="index.jsp">首页</a>
</li>
</ul>
</div>
<!--头部开始-->
<div class="container">
<div class="header">
<img src="images/index_logo.png" />
<p>
<img src="images/zhuce_title.png" />
</p>
</div>
<div class="main clearfix">
<div class="mani-biao fl">
<div class="button clearfix">
<p class=&quo