<!doctypehtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
</head>
<body>
用户名:<inputid="userName">
密码:<inputtype="password">
密码:<inputtype="password">
<buttononclick="sub()">注册</button>
<scriptsrc="jquery-2.1.1.min.js"></script>
<script>
varuserName,
password,
password2;
functionsub(){
userName=$('#userName').val();
password=$('input[type="password"]')[0].value;
password2=$('input[type="password"]')[1].value;
if(userName.length<4||userName.length>10){
alert('用户名长度为4~10位');
return;
}
if(!password||!password2){
alert('密码为空');
return;
}
if(password!==password2){
alert('两次密码输入不一样,请重新输入');
return;
}
alert('注册成功');
}
</script>
</body>
</html>
㈡ 刚刚学JQuery,请问怎么写一个JQuery验证登录密码的,代码应该怎么写,急
页面代码:
<input type="password" name="pass" id="pass" />
<span id="passstrength"></span>
以下是JS代码:
$('#pass').keyup(function(e) {
var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
var enoughRegex = new RegExp("(?=.{6,}).*", "g");
if (false == enoughRegex.test($(this).val())) {
$('#passstrength').html('More Characters');
} else if (strongRegex.test($(this).val())) {
$('#passstrength').className = 'ok';
$('#passstrength').html('Strong!');
} else if (mediumRegex.test($(this).val())) {
$('#passstrength').className = 'alert';
$('#passstrength').html('Medium!');
} else {
$('#passstrength').className = 'error';
$('#passstrength').html('Weak!');
}
return true;
});
㈢ 仿百度登陆弹窗的JS或者jquery代码 求详细
<!DOCTYPEhtml>
<html>
<head>
<metacharset="utf-8"/>
<title>div布局</title>
<scripttype="text/javascript"src="http://libs..com/jquery/1.3.2/jquery.min.js"></script>
<styletype="text/css">
.corInsertHref
{
position:absolute;
z-index:10000;
width:370px;
float:left;
display:none;
background-color:#fff;
padding:10px;
}
.corBackground
{
width:100%;
height:100%;
position:absolute;
background-color:#000;
top:0;
left:0;
filter:alpha(opacity=30);
-moz-opacity:0.30;
-khtml-opacity:0.30;
opacity:0.30;
z-index:9999;
display:none;
}
</style>
<scripttype="text/javascript">
$(function(){
//点击登录按钮弹出层并初始化弹出层位置
$("#btnlogin").click(function(){
$("#corBackground").animate({opacity:"show"},"slow");
$("#corInsertHref").animate({opacity:"show"},"slow");
autoSize($("#corInsertHref"));
});
//窗口大小缩放事件
$(window).resize(function(){
autoSize($("#corInsertHref"));
});
//窗口大小缩放时调整弹出层的位置
varautoSize=function(corObj){
varwWidth=$(window).width(),wHeight=$(window).height();
varihWidth=corObj.outerWidth(true),ihHeight=corObj.outerHeight(true);
corObj.css({"top":((wHeight-ihHeight)/2)+"px","left":((wWidth-ihWidth)/2)+"px"});
}
});
</script>
</head>
<body>
<spanid="btnlogin">登录</span>
<divid="corInsertHref"class="corInsertHref">
<p>
账号<inputid="txtName"type="text"/></p>
<p>
密码<inputid="txtPwd"type="text"/></p>
<p>
<inputtype="button"value="登录"/></p>
</div>
<divid="corBackground"class="corBackground">
</div>
</body>
</html>
粗略的写了下,可以吗?
㈣ 利用 jquery ajax做一个用户登录界面
a页面关键JS代码:
function che(username,pwd){
$.ajax({
url:"b.aspx",
type:"POST",
data:{user:username,pwd:pwd},
dataType:"XML",
success: function (data,status){
var count=$(data).find("num").text();
if(count==0){ //没有注册
$("#lab2").html("未注册,不能登录");
}
else{ //已经注册
$("#lab2").html("可以登录");
……
} //else
} //success
}); //ajax
}
b页面中要返回xml数据,拼字符串就可以
string user = Request["user"].ToString(); //获取用户名
string pwd = Request["pwd"].ToString(); //获取密码
count=根据用户名和密码查询出来的记录数
//sql语句:select count(*) from login where username=user and password=pwd
string str = "<?xml version='1.0' ?>";
str += "<num>" + count + "</num>";
Response.Write(str);
Response.End();