Advertisement
Guest User

Untitled

a guest
Oct 11th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. $('button.add_account').on('click', function () {
  2. var date = moment().format('YYYY-MM-DD');
  3. var time = moment().format('H:mm');
  4. var username = $('.username').empty().val();
  5. var password = $('.password').empty().val();
  6. var phone = $('.phone').empty().val();
  7. var email = $('.email').empty().val();
  8. var level = $('select.level').val();
  9. if (username.length !==0 || password.length !==0 || phone.length !==0|| email.length !==0|| level.length !==0) {
  10. swal
  11. ({
  12. text: "فضلا إنتظر",
  13. icon: "info",
  14. button: null
  15.  
  16. });
  17. $.post("/add_new_account/",
  18. {
  19. username: username,
  20. password: password,
  21. level: level[0],
  22. phone: phone,
  23. email: email,
  24. date: date,
  25. time: time
  26. })
  27. .done(function (response) {
  28. if (response == "0")
  29. {
  30. swal({
  31. text: "تم إضافة الحساب بنجاح",
  32. icon: "success",
  33. button: null,
  34. timer: 3000
  35. });
  36. }
  37. else if (response == "1")
  38. {
  39. swal({
  40. text: "بيانات الحساب موجودة مسبقا",
  41. icon: "error",
  42. button: null,
  43. timer: 3000
  44. });
  45. }
  46. else
  47. {
  48. swal({
  49. text: "حدث خطأ مفاجئ",
  50. icon: "warning",
  51. button: null,
  52. timer: 3000
  53. });
  54. }
  55. return false;
  56. })
  57. }
  58. else
  59. {
  60. swal({
  61. text: "فضلا إملئ جميع الحقول",
  62. icon: "warning",
  63. button: null,
  64. timer: 3000
  65. });
  66. }
  67.  
  68. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement