国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

JS簡單實現(xiàn)登陸驗證附效果圖

2024-05-06 15:55:33
字體:
供稿:網(wǎng)友
實現(xiàn)登陸驗證的方法有很多,在本文為大家詳細(xì)介紹下使用js是如何做到的,下面有個不錯的示例還有運行截圖,喜歡的朋友可以嘗試操作下

源代碼:

復(fù)制代碼 代碼如下:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta content="劉江波">
<script type="text/javascript">
function login(){
var userName=document.getElementById("userName").value;
var pwd=document.getElementById("pwd").value;
var repwd=document.getElementById("repwd").value;
var address=document.getElementById("address").value;
var matchResult=true;
if(userName==""||pwd==""||repwd==""||address==""){
alert("請確認(rèn)是否有空缺項!");
matchResult=false;
}else if(userName.length<6||userName.length>20){
alert("用戶名長度應(yīng)在6到20個字符之間!");
matchResult=false;
}else if(userName==pwd||userName==repwd){
alert("密碼或重復(fù)密碼不能和用戶名相同!");
matchResult=false;
}else if(pwd.length<6||pwd.length>20||repwd.length<6||repwd.length>20){
alert("密碼或重復(fù)密碼長度應(yīng)在6到20個字符之間!");
matchResult=false;
}else if(pwd!=repwd){
alert("密碼和重復(fù)密碼不同,請重新輸入!");
matchResult=false;
}else if(userName.length<6||userName.length>20){
alert("用戶名長度應(yīng)在6到20個字符之間!");
matchResult=false;
}

if(matchResult==true){
var mailreg = /^/w+@/w+(/./w+)+$/;
if(!address.match(mailreg)){
alert("郵箱格式不正確");
matchResult=false;
}
}


if(matchResult==true){
if(userName.charAt(0)>=0&&userName.charAt(0)<=9){
alert("用戶名不能以數(shù)字字符開始!");
matchResult=false;
}
}

return matchResult;
}
</script>
<title>用戶注冊及驗證</title>
</head>

<body>
<center>
<form action="http://www.ytu.edu.cn" onsubmit="return login()" method="post">
<table bgcolor="#6666FF" cellspacing="0" cellpadding="0" valign="top">
<tr>
<td colspan="2" bgcolor="#3366FF">用戶注冊</td>
</tr>
<tr>
<td>登錄用戶名</td>
<td><input type="text"></td>
</tr>
<tr>
<td>登錄密碼</td>
<td><input type="password"></td>
</tr>
<tr>
<td>重復(fù)輸入密碼</td>
<td><input type="password"></td>
</tr>
<tr>
<td>有效郵箱地址</td>
<td><input type="text"></td>
</tr>
<tr>

<!--<td></td>-->
<td colspan="2">
<input type="submit" value="登錄">
<input type="button" value="取消"></td>
</tr>
</table>
</form>
</center>

</body>
</html>


效果實現(xiàn):

JS簡單實現(xiàn)登陸驗證附效果圖

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 昭苏县| 汾西县| 和平区| 七台河市| 临沧市| 赣榆县| 宜黄县| 永靖县| 兴安县| 垫江县| 申扎县| 盈江县| 广南县| 周口市| 新巴尔虎左旗| 上饶县| 当雄县| 张家口市| 团风县| 开鲁县| 荣成市| 阿拉尔市| 长兴县| 南木林县| 和田市| 浦东新区| 宜宾县| 乡城县| 文成县| 大洼县| 长子县| 昌宁县| 广德县| 鄢陵县| 凭祥市| 宁化县| 灌阳县| 邵阳县| 云浮市| 张家界市| 昂仁县|