register.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. $(document).ready(function () {
  2. var timer = null;
  3. timer = setInterval(function () {
  4. $(".zhedang").hide();
  5. }, 400)
  6. document.addEventListener('gesturestart', function (e) {
  7. e.preventDefault();
  8. });
  9. document.addEventListener('dblclick', function (e) {
  10. e.preventDefault();
  11. });
  12. document.addEventListener('touchstart', function (event) {
  13. if (event.touches.length > 1) {
  14. event.preventDefault();
  15. }
  16. });
  17. var lastTouchEnd = 0;
  18. document.addEventListener('touchend', function (event) {
  19. var now = (new Date()).getTime();
  20. if (now - lastTouchEnd <= 300) {
  21. event.preventDefault();
  22. }
  23. lastTouchEnd = now;
  24. }, false);
  25. var timer = null;
  26. function publicBox(publicText) {
  27. $(".AlertBox").show();
  28. $(".AlertBoxChilds").html(publicText);
  29. timer = setInterval(function () {
  30. $(".AlertBox").hide();
  31. }, 2000)
  32. }
  33. function publicBoxBack(publicText) {
  34. $(".AlertBox").show();
  35. $(".AlertBoxChilds").html(publicText);
  36. timer = setInterval(function () {
  37. $(".AlertBox").hide();
  38. window.history.back();
  39. }, 2000)
  40. }
  41. $(".registerShuomingBackBtn").on("click", function () {
  42. window.history.back();
  43. })
  44. $(".LoginBtn").on("click", function () {
  45. clearInterval(timer)
  46. if ($("#account").val() == "") {
  47. publicBox("Please fill in the account number");
  48. } else if ($("#password").val() == "") {
  49. publicBox("Please fill in the password");
  50. } else if ($("#repeatpassword").val() == "") {
  51. publicBox("Please repeat the password");
  52. } else if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,12}$/.test($("#account").val())) {
  53. publicBox("Length 8-12 digits + letters");
  54. } else if ($("#password").val() != $("#repeatpassword").val()) {
  55. publicBox("The two passwords are inconsistent");
  56. } else if (!/^\d{6}$/.test($("#repeatpassword").val())) {
  57. publicBox("Please enter a 6-digit password");
  58. } else if (!/^\d{6}$/.test($("#password").val())) {
  59. publicBox("Please enter a 6-digit password");
  60. } else {
  61. $.ajax({
  62. type: "post",
  63. url: "https://www.bibidd.com/bibidd/user/slUserRegister",
  64. dataType: "json",
  65. data: {
  66. account: $("#account").val(),
  67. password: $("#password").val()
  68. },
  69. success: function (res) {
  70. if (res.code == "200") {
  71. publicBoxBack("Registered successfully")
  72. } else if (res.code == "201") {
  73. publicBox("Registration failed. Please try again");
  74. } else if (res.code == "202") {
  75. publicBox("Incorrect parameters");
  76. } else if (res.code == "203") {
  77. publicBox("The account has already been registered");
  78. }
  79. }
  80. })
  81. }
  82. })
  83. })