我正在进行如下的 JQuery 验证:(我不太了解 jquery)..
我无法完成以下事情:
- 只允许使用字母 a 到 z(小写)、“-”(破折号或连字符)和“”(空格),
- 必须输入“-”(破折号)和“”(空格)字母,
- “-”或“”字母不能是输入的第一个或最后一个字母,
- “-”不能是“”的直接邻居或相邻(之前或之后),
- “-”或“”不能是其自身的直接邻居(相邻)。
- “电话”号码字段(4 位区号、一个空格、7 位本地代码)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script type="text/javascript"
src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js">
</script>
<script>
$(document).ready(function(){
$("#commentForm").validate({
onfocusout: function(element) { $(element).valid(); } ,
rules: {
fullname : {
required: true,
maxlength: 14,
},
email: {
required: true,
email: true
}
},
messages: {
fullname : {
required: "Please specify your Full Name",
maxlength: "Please enter only upto 14 characters",
},
email: {
required: "We need your email address to contact you",
email: "Your email address must be in the format of name@domain.com"
}
}
});
});
</script>
</head>
<body>
<form id="commentForm" method="get" action="">
<fieldset>
<p>
<label for="fullname">Full Name</label>
<em>*</em><input id="fullname" name="fullname" size="25" class="required" maxlength="14" />
</p>
<p>
<label for="email">E-Mail</label>
<em>*</em><input id="email" name="email" size="25" class="required email" />
</p>
</fieldset>
</form>
</body>
</html>
请有人帮助我实现这一目标..?