jquery實(shí)現(xiàn)用戶登陸界面(示例講解)
更新時(shí)間:2017年09月06日 08:06:11 作者:煙花盛典
下面小編就為大家?guī)硪黄猨query實(shí)現(xiàn)用戶登陸界面(示例講解)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
實(shí)例如下所示:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<script src="js/jquery-1.8.0.min.js"></script>
<script>
var cnresu = false;
$(function(){
$("input[name='uname']").blur(function(){//blur從鏈接上移開焦點(diǎn)(鼠標(biāo)離開框時(shí))
var unamestr = $(this).val();
var regstr = /^[\u4e00-\u9fa5]{2,4}$/;
if(!regstr.test(unamestr)){
$(this).parent().next("dd").html("必須是2-4個(gè)漢字");
cnresu = false;
return;
}
cnresu = true;
});
$("input[name='uname']").focus(function(){//focus給予鏈接焦點(diǎn)(鼠標(biāo)點(diǎn)中框時(shí))
$(this).css("border","solid 1px #dddddd");
//$(this).val("");
$(this).parent().next("dd").html("");
});
});
</script>
<style>
#home{
width: 600px;
height: 300px;
margin: auto;
background-color: #7FFFD4;
}
#head{
padding-top: 20px;
height: 100px;
}
.dl1{
clear: both;
}
.dl1 dt{
float: left;
text-align: right;
width: 150px;
height: 30px;
line-height: 30px;
}
.dl1 dd{
float: left;
height: 30px;
line-height: 30px;
}
#foot{
text-align: center;
}
h1{
padding-top: 20px;
text-align: center;
color: bisque;
}
</style>
<body>
<div id="home">
<h1>用戶登陸</h1>
<div id="head">
<form action="biaodan.html" name="regform" method="post" >
<dl class="dl1">
<dt>用戶名 : </dt>
<dd><input type="text" name="uname"/></dd>
<dd id="erroruname"></dd>
</dl>
<dl class="dl1">
<dt>密碼 : </dt>
<dd><input type="password"/></dd>
<dd id="errorpass"></dd>
</dl>
</div>
<div id="foot">
<input type="submit" value="提交"/>
<input type="reset" value="重置"/>
</div>
</form>
</div>
</body>
</html>
運(yùn)行截圖

以上這篇jquery實(shí)現(xiàn)用戶登陸界面(示例講解)就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
jquery修改屬性值實(shí)例代碼(設(shè)置屬性值)
jQuery attr()方法用于設(shè)置/改變屬性值,下面的例子演示如何改變(設(shè)置)鏈接中 href 屬性的值2014-01-01
Jquery和Js獲得元素標(biāo)簽名稱的方法總結(jié)
下面小編就為大家?guī)硪黄狫query和Js獲得元素標(biāo)簽名稱的方法總結(jié)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-10-10
把jquery 的dialog和ztree結(jié)合實(shí)現(xiàn)步驟
首先準(zhǔn)備好juqury-ui、ztree 的js文件和css 文件,接下來的步驟祥看本文希望對(duì)大家有所幫助2013-08-08
jQuery 淡入淡出 png圖在ie8下有黑色邊框的解決方法
本文章介紹了,jQuery 淡入淡出 png圖在ie8下有黑色邊框的解決方法,需要的朋友可以參考一下2013-03-03
jQuery contains過濾器實(shí)現(xiàn)精確匹配使用方法
contains 選擇器選取包含指定字符串的元素。該字符串可以是直接包含在元素中的文本,或者被包含于子元素中。經(jīng)常與其他元素/選擇器一起使用,來選擇指定的組中包含指定文本的元素2013-04-04

