查看: 256|回复: 0

[HTML代码] WebApp之H5登录注册

发表于 7 天前

代码indexhtml

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>TencentQQ</title>
  6. <meta name="viewport" content="width=device-width,initial-scale=1">
  7. <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
  8. <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
  9. <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
  10. <script type="text/javascript" src="js/index.js" ></script>
  11. </head>
  12. <body>
  13. <!--登陆页面-->
  14. <div data-role="page" id="pageLogin">
  15. <div data-role="header">
  16. <h1 role="heading">Tencent办公系统</h1>
  17. </div>
  18. <div data-role="main" class="ui-content">
  19. <form method="get" action="">
  20. <div class="ui-field-contain">
  21. <label for="name">帐号:</label>
  22. <input type="text" name="u_name" id="u_name">
  23. <br/>
  24. <label for="password">密码:</label>
  25. <input type="password" name="u_password" id="u_password">
  26. <div style="margin-top: 20%;">
  27. <input type="button" value="登录" onclick="login()" />
  28. <a href="#pagetwo" data-role="button" data-transition="flip">注册</a>
  29. </div>
  30. <h5 style="color: red;">测试登录帐号:admin 密码:admin888</h5>
  31. <h5 style="color: red;">测试登录帐号:root 密码:123456</h5>
  32. </div>
  33. </form>
  34. </div>
  35. <div data-role="footer" style="text-align: center" data-position="fixed">
  36. <p>Copyright ? 1998 - 2017 Tencent</p>
  37. </div>
  38. </div>
  39. <!--注册页面-->
  40. <div data-role="page" id="pagetwo" data-theme="b">
  41. <div data-role="header">
  42. <h1>欢迎注册Tencent</h1>
  43. </div>
  44. <div data-role="main" class="ui-content">
  45. <form method="get" action="">
  46. <div class="ui-field-contain">
  47. <label for="Rname">帐号:</label>
  48. <input type="text" name="u_name1" id="u_name1">
  49. <br/>
  50. <label for="Rpassword">密码:</label>
  51. <input type="password" name="u_password1" id="u_password1">
  52. <br/>
  53. <label for="Repassword">重复密码:</label>
  54. <input type="password" name="u_password2" id="u_password2">
  55. <div style="margin-top: 20%;">
  56. <input type="button" value="确定注册" onclick="register()" />
  57. <a href="#pageLogin" data-role="button" data-transition="flip" data-direction="reverse">返回</a>
  58. </div>
  59. </div>
  60. </form>
  61. </div>
  62. <div data-role="footer" style="text-align: center" data-position="fixed">
  63. <p>Copyright ? 1998 - 2017 Tencent</p>
  64. </div>
  65. </div>
  66. </body>
  67. </html>
复制代码

  index.js

  1. //测试登录
  2. function login() {
  3. var u_user = document.getElementById("u_name").value;
  4. var u_password = document.getElementById("u_password").value;
  5. if((u_user == "admin") && (u_password == "admin888")) {
  6. alert("登录成功!不作处理!");
  7. } else {
  8. alert("用户名或者密码错误,登录失败!");
  9. location.href = "index.html#pageLogin";
  10. }
  11. }
  12. //测试注册
  13. function register() {
  14. var u_user1 = document.getElementById("u_name1").value;
  15. var u_password1 = document.getElementById("u_password1").value;
  16. var u_password2 = document.getElementById("u_password2").value;
  17. if((u_user1 == "root") && (u_password1 == "123456") && (u_password2 == u_password1)) {
  18. alert("注册成功!返回登录页面!");
  19. location.href = "index.html#pageLogin";
  20. } else {
  21. alert("注册失败,返回登录页面!");
  22. location.href = "index.html#pageLogin";
  23. }
  24. }
复制代码

  



回复

使用道具 举报