<!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();