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="登录" οnclick="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="确定注册" οnclick="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";
	}
}

  

转载于:https://www.cnblogs.com/ceet/p/7444334.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值