<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<script type='text/javascript' src='jquery1.8.2.js'></script>
</head>
<body>
<form id="passForm" action="/wxkmsvc/dataService?app=mobile&controller=member&action=doresetpassword" method="POST">
<div class="check_box">
<div>
<label>新密码:</label>
<input id="password" type="password" name="password"><span style="color:red" id="passwordNote"></span>
</div>
<div>
<label>确认密码:</label>
<input id="repassword" type="password" name="repassword"><span style="color:red" id="repasswordNote"></span>
</div>
<div>
<input class="sub_button" id="Button1" type="submit" value="提交"/>
</div>
</div>
</form>
<script type="text/javascript">
/* //focusin事件为光标进入,focusout为光标离开
$("#password").focusin(function () {
$("#passwordNote").html("密码长度在6-16位之间!");
}).focusout(function () {
if ($("#password").val() == "")
$("#passwordNote").html("密码长度在6-16位之间!");
else
$("#passwordNote").html("");
}); */
$(function () {
$("#password").focusout(function () {
if ($("#password").val() == "" || $("#password").val().length < 6 || $("#password").val().length > 16)
$("#passwordNote").html("密码长度在6-16位之间!");
else
$("#passwordNote").html("");
});
$("#repassword").focusout(function () {
if ($("#repassword").val() == "" || $("#repassword").val().length < 6 || $("#repassword").val().length > 16 || $("#password").val() != $("#repassword").val())
$("#repasswordNote").html("密码长度在6-16位之间且两次输入密码需一致!");
else
$("#repasswordNote").html("");
});
$("#passForm").submit(function() {
var password = $("#password").val();
var repassword = $("#repassword").val();
if ($.trim(password) == "" || $.trim(repassword) != $.trim(password) || $.trim(password).length <3 || $.trim(password).length >16) {
return false;
}
else {
return true;
}
});
});
</script>
</body>
</html>
jquery表单验证
最新推荐文章于 2023-01-05 17:15:22 发布