jquery validate 验证通过样式问题
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/...
<!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>
<script src="jquery-1.9.1.js"></script>
<script src="jquery.validate.js"></script>
<script>
$().ready(function(){
$("#form1").validate({
focusCleanup:true,
rules:{
username:{
required:true
},
password:{
required:true,
minlength:6
},
confirm_password:{
required:true,
minlength:6,
equalTo:'#password'
}
},
messages:{
username:"请输入姓名",
password:{
required:"请输入密码",
minlength:"长度不少于6"
},
confirm_password:{
required:"请输入密码",
minlength:"长度不少于6",
equalTo:"密码不一致"
}
},
errorClass:"error",
success:function(label){
label.html("<span style=\"color:green;\">填写正确!</span>").addClass("success");
}
}
);
} );
</script>
<br />
<style>
label.error
{
padding-left:25px;
background:url(images/t01a8abfa29e21c6fc2.png);
background-repeat:no-repeat;
color:Red;
}
label.success{
padding-left:25px;
background-image:url(images/t01acea87b9ad67be08.jpg);
background-repeat:no-repeat;
}
</style>
</head>
<body>
<form id="form1" method="post" action="#">
用户名:<input name="username" type="text"/><br /><br />
密码:<input name="password" type="password" id="password" /><br /><br />
确认密码:<input name="confirm_password" type="password" /><BR />
<input type="submit"value="确认" />
<input type="reset"value="重写" />
</form>
</body>
</html>
这是我的代码,求改掉bug 展开
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="jquery-1.9.1.js"></script>
<script src="jquery.validate.js"></script>
<script>
$().ready(function(){
$("#form1").validate({
focusCleanup:true,
rules:{
username:{
required:true
},
password:{
required:true,
minlength:6
},
confirm_password:{
required:true,
minlength:6,
equalTo:'#password'
}
},
messages:{
username:"请输入姓名",
password:{
required:"请输入密码",
minlength:"长度不少于6"
},
confirm_password:{
required:"请输入密码",
minlength:"长度不少于6",
equalTo:"密码不一致"
}
},
errorClass:"error",
success:function(label){
label.html("<span style=\"color:green;\">填写正确!</span>").addClass("success");
}
}
);
} );
</script>
<br />
<style>
label.error
{
padding-left:25px;
background:url(images/t01a8abfa29e21c6fc2.png);
background-repeat:no-repeat;
color:Red;
}
label.success{
padding-left:25px;
background-image:url(images/t01acea87b9ad67be08.jpg);
background-repeat:no-repeat;
}
</style>
</head>
<body>
<form id="form1" method="post" action="#">
用户名:<input name="username" type="text"/><br /><br />
密码:<input name="password" type="password" id="password" /><br /><br />
确认密码:<input name="confirm_password" type="password" /><BR />
<input type="submit"value="确认" />
<input type="reset"value="重写" />
</form>
</body>
</html>
这是我的代码,求改掉bug 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询