<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="../../js/jquery-1.8.2.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
$("#zhuce").click(function(){
$("span").html("");
var name=$("#name").val();
var pwd=$("#pwd").val();
var qpwd=$("#qpwd").val();
var email=$("#email").val();
var tel=$("#tel").val();
if (name.length>=4) {
$("#s1").html("√").css("color","green");
}else{
$("#s1").html("×").css("color","red");
return;
}
if (pwd.length>=6) {
$("#s2").html("√").css("color","green");
}else{
$("#s2").html("×").css("color","red");
return;
}
if (pwd==qpwd) {
$("#s3").html("√").css("color","green");
}else{
$("#s3").html("×").css("color","red");
return;
}
if (email.indexOf("@")!=-1) {
$("#s4").html("√").css("color","green");
}else{
$("#s4").html("×").css("color","red");
return;
}
if (tel.length==11) {
$("#s5").html("√").css("color","green");
}else{
$("#s5").html("×").css("color","red");
return;
}
alert("注册成功");
})
})
</script>
</head>
<body>
用户名:<input type="text" id="name" /><span id="s1"></span><br />
密码:<input type="password" id="pwd" /><span id="s2"></span><br />
确认密码:<input type="password" id="qpwd" /><span id="s3"></span><br />
邮箱:<input type="email" id="email" /><span id="s4"></span><br />
手机号码:<input type="tel" id="tel" /><span id="s5"></span><br />
<button id="zhuce">注册</button>
</body>
</html>
jquery 简单验证
最新推荐文章于 2024-06-29 14:47:07 发布