摘要:本文将带你了解WebApp源码之H5登录注册,希望本文对大家学WEBAPP有所帮助。
代码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="//code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" /> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <script src="//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"> <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"> <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"; } }
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标移动开发之WebApp频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号