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

首頁 > 編程 > JavaScript > 正文

JS簡單實現登陸驗證附效果圖

2019-11-20 21:39:27
字體:
來源:轉載
供稿:網友
源代碼:
復制代碼 代碼如下:

<!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 name="Author" 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("請確認是否有空缺項!");
matchResult=false;
}else if(userName.length<6||userName.length>20){
alert("用戶名長度應在6到20個字符之間!");
matchResult=false;
}else if(userName==pwd||userName==repwd){
alert("密碼或重復密碼不能和用戶名相同!");
matchResult=false;
}else if(pwd.length<6||pwd.length>20||repwd.length<6||repwd.length>20){
alert("密碼或重復密碼長度應在6到20個字符之間!");
matchResult=false;
}else if(pwd!=repwd){
alert("密碼和重復密碼不同,請重新輸入!");
matchResult=false;
}else if(userName.length<6||userName.length>20){
alert("用戶名長度應在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("用戶名不能以數字字符開始!");
matchResult=false;
}
}

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

<body>
<center>
<form name="loginForm" action="http://www.ytu.edu.cn" onsubmit="return login()" method="post">
<table bgcolor="#6666FF" width="300" cellspacing="0" cellpadding="0" border="0" align="left" valign="top">
<tr>
<td class="table-title" colspan="2" align="center" bgcolor="#3366FF">用戶注冊</td>
</tr>
<tr>
<td width="130" height="28" align="left">登錄用戶名</td>
<td><input id="userName" name="userName" type="text" class="input"></td>
</tr>
<tr>
<td width="80" height="28" align="left">登錄密碼</td>
<td><input id="pwd" name="pwd" type="password" class="input"></td>
</tr>
<tr>
<td width="80" height="28" align="left">重復輸入密碼</td>
<td><input id="repwd" name="repwd" type="password" class="input"></td>
</tr>
<tr>
<td width="80" height="28" align="left">有效郵箱地址</td>
<td><input id="address" name="address" type="text" class="input"></td>
</tr>
<tr>

<!--<td width="10" height="28" align="left"></td>-->
<td colspan="2">
<input type="submit" value="登錄">
<input type="button" value="取消" onClick="reset()"></td>
</tr>
</table>
</form>
</center>

</body>
</html>

效果實現:
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 偏关县| 肇东市| 郯城县| 富顺县| 济南市| 星子县| 阳山县| 南丰县| 昌邑市| 青浦区| 孟连| 山阳县| 灵宝市| 安丘市| 会宁县| 峨眉山市| 富阳市| 白银市| 嘉善县| 吴江市| 建平县| 通城县| 东源县| 新化县| 中山市| 大石桥市| 房产| 丹阳市| 法库县| 星座| 龙岩市| 锦州市| 聊城市| 肇东市| 方城县| 麻城市| 永福县| 巢湖市| 离岛区| 酒泉市| 金沙县|