您好,登錄后才能下訂單哦!
1 插件支持IE8及以上的版本,不再支持IE6、7;
2 使用范圍:企業級別的系統開發(用戶數目幾十到幾千人也行),統一安裝IE8以上的瀏覽器即可;
3 如果是企業級宣傳網站,則不能使用;
html:
<script src="js/jquery-1.11.3.js"></script>
<script src="js/jquery.validate.js"></script>
<!--<script src="js/jquery-migrate-1.2.1.js"></script>-->
<script type="text/javascript">
$(function () {
$("#reg").validate({
//驗證成功后,提交數據,使用AJAX提交
submitHandler: function (form) {
$.ajax({
type: "post",
url: "Submit.aspx",
data: $(form).serialize(),
success: function (response, status, xhr) {
if (response == "ok") {
window.location = "HtmlPage2.html";
}
else {
alert("注冊失敗!");
}
},
error: function () {
alert("ajax服務器錯誤!");
}
});
},
//驗證成功,添加一個對號圖片
success: function (lable) {
lable.html('<img src="../img/aa.png" alt="" />');
},
//驗證規則
rules: {
userName: {
required: true,//不為空
remote: "Ajax.aspx?action=dan"
},
pwd: {
required: true,//不為空
minlength: "6",
},
confirmPwd: {
required: true,
equalTo: "#userPwd"http://和密碼是否相等
},
email: {
required: true,
email: true
},
tsPwd: {
required: true,
geshi:true
}
},
messages: {
userName: {
required: '<span class="errorMes">用戶名不能為空!</span>',
remote: '<span class="errorMes">用戶名已存在,請重新輸入!</span>',
},
pwd: {
required: '<span class="errorMes">密碼不能為空!</span>',
minlength: jQuery.format('<span class="errorMes">密碼不能少于{0}位!</span>'),
},
confirmPwd: {
required: '<span class="errorMes">確認密碼不能為空!</span>',
equalTo: '<span class="errorMes">密碼不一致,請重新輸入!</span>'
},
email: {
required: '<span class="errorMes">郵箱不能為空!</span>',
email: '<span class="errorMes">郵箱格式不正確!</span>'
},
tsPwd: {
required: '<span class="errorMes">不能為空!</span>',
}
}
});
////單獨添加
//$("#tsPwd").rules("add", {
// required: true,
// geshi: true,
// messages: {
// required: '<span class="errorMes">不能為空!</span>',
// }
//});
//自定義驗證規則
$.validator.addMethod("geshi", function (value,element) {
var reg = /^((\w*\d\w*[a-z]\w*)|(\w*[a-z]\w*\d\w*))$/i;
return this.optional(element)||(reg.test(value));
},'必須是數字和字母或下劃線的組合!');
});
</script>
<style type="text/css">
.star, .errorMes {
color: red;
font-weight: bold;
}
</style>
</head>
<body>
<form id="reg" >
<input type="hidden" name="action" value="ChaJianVal" />
<p>用戶名:<input id="userName" type="text" name="userName" /><label id="isExist"></label><span class="star">*</span></p>
<p>密碼:<input id="userPwd" type="text" name="pwd" /><span class="star">*</span></p>
<p>確認密碼:<input type="text" name="confirmPwd" /><span class="star">*</span></p>
<p>郵箱:<input type="text" name="email" /><span class="star" >*</span></p>
<p>特殊密碼:<input type="text" name="tsPwd" id="tsPwd" /><span class="star">*</span></p>
<p><input id="sub" type="submit" value="提交" /></p>
</form>
</body>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。