Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. //ON CLICK BUTTON REGISTER
  2. $('#register').click(function () {
  3. //DEF VARIABLE INPUT
  4. var username = $("#username").val();
  5. var email = $("#email").val();
  6. var password = $("#password").val();
  7. var passwordc = $("#passwordc").val();
  8. //IF INPUT ARE EMPTY
  9. if (username == "" || email == "" || password == "" || passwordc == "")
  10. {
  11. swal({
  12. type: 'error',
  13. title: error_fill_fields,
  14. showConfirmButton: false,
  15. timer: 2000
  16. })
  17. }
  18. //EMAIL FORMAT
  19. else if (!validateEmail(email))
  20. {
  21. swal({
  22. type: 'error',
  23. title: error_email_format,
  24. showConfirmButton: false,
  25. timer: 2000
  26. })
  27.  
  28. }
  29. //PASSWORD VERIFY
  30. else if (password != passwordc)
  31. {
  32. swal({
  33. type: 'error',
  34. title: error_password_passwordc,
  35. showConfirmButton: false,
  36. timer: 2000
  37. })
  38. }
  39. else
  40. {
  41. $.ajax({
  42. url: 'actionAccountCtrlr-register.php',
  43. type: 'POST',
  44. data: 'username=' + username + '&email=' + email + '&password=' + password,
  45. dataType: 'html',
  46. success: function (data) {
  47. if (data == "username")
  48. {
  49. swal({
  50. type: 'error',
  51. title: error_username_use,
  52. showConfirmButton: false,
  53. timer: 2000
  54. })
  55. }
  56. else if (data == "email")
  57. {
  58. swal({
  59. type: 'error',
  60. title: error_email_use,
  61. showConfirmButton: false,
  62. timer: 2000
  63. })
  64. }
  65. else if (data == "success")
  66. {
  67. swal({
  68. type: 'success',
  69. title: success_register,
  70. text: success_redirection,
  71. showConfirmButton: false,
  72. timer: 3000
  73. })
  74. window.setTimeout(function() {
  75. window.location.href = '/';
  76. }, 3000);
  77. }
  78. else
  79. {
  80. swal({
  81. type: 'error',
  82. title: error_attempt,
  83. showConfirmButton: false,
  84. timer: 2000
  85. })
  86. }
  87. }
  88.  
  89. });
  90. }
  91. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement