WebApp之H5登錄注冊


代碼indexhtml

<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>TencentQQ</title>
		<meta name="viewport" content="width=device-width,initial-scale=1">
		<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
		<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
		<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
		<script type="text/javascript" src="js/index.js" ></script>
	</head>

	<body>
		<!--登陸頁面-->
		<div data-role="page" id="pageLogin">
			<div data-role="header">
				<h1 role="heading">Tencent辦公系統</h1>
			</div>
			<div data-role="main" class="ui-content">
				<form method="get" action="">
					<div class="ui-field-contain">
						<label for="name">帳號:</label>
						<input type="text" name="u_name" id="u_name">
						<br/>
						<label for="password">密碼:</label>
						<input type="password" name="u_password" id="u_password">
						<div style="margin-top: 20%;">
							<input type="button" value="登錄" onclick="login()" />
							<a href="#pagetwo" data-role="button" data-transition="flip">注冊</a>
						</div>
						<h5 style="color: red;">測試登錄帳號:admin 密碼:admin888</h5>
						<h5 style="color: red;">測試登錄帳號:root 密碼:123456</h5>
					</div>
				</form>
			</div>
			<div data-role="footer" style="text-align: center" data-position="fixed">
				<p>Copyright © 1998 - 2017 Tencent</p>
			</div>
		</div>
		<!--注冊頁面-->
		<div data-role="page" id="pagetwo" data-theme="b">
			<div data-role="header">
				<h1>歡迎注冊Tencent</h1>
			</div>
			<div data-role="main" class="ui-content">
				<form method="get" action="">
					<div class="ui-field-contain">
						<label for="Rname">帳號:</label>
						<input type="text" name="u_name1" id="u_name1">
						<br/>
						<label for="Rpassword">密碼:</label>
						<input type="password" name="u_password1" id="u_password1">
						<br/>
						<label for="Repassword">重復密碼:</label>
						<input type="password" name="u_password2" id="u_password2">
						<div style="margin-top: 20%;">
							<input type="button" value="確定注冊" onclick="register()" />
							<a href="#pageLogin" data-role="button" data-transition="flip" data-direction="reverse">返回</a>
						</div>
					</div>
				</form>
			</div>
			<div data-role="footer" style="text-align: center" data-position="fixed">
				<p>Copyright © 1998 - 2017 Tencent</p>
			</div>
		</div>

	</body>

</html>

  index.js

//測試登錄
function login() {
	var u_user = document.getElementById("u_name").value;
	var u_password = document.getElementById("u_password").value;
	if((u_user == "admin") && (u_password == "admin888")) {
		alert("登錄成功!不作處理!");
	} else {
		alert("用戶名或者密碼錯誤,登錄失敗!");
		location.href = "index.html#pageLogin";
	}
}
//測試注冊
function register() {
	var u_user1 = document.getElementById("u_name1").value;
	var u_password1 = document.getElementById("u_password1").value;
	var u_password2 = document.getElementById("u_password2").value;
	if((u_user1 == "root") && (u_password1 == "123456") && (u_password2 == u_password1)) {
		alert("注冊成功!返回登錄頁面!");
		location.href = "index.html#pageLogin";
	} else {
		alert("注冊失敗,返回登錄頁面!");
		location.href = "index.html#pageLogin";
	}
}

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM