login.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. $(function () {
  2. const id = $("input[name = 'user_id']");
  3. const pwd = $("input[name = 'pwd']");
  4. const logBtn = $(".input-box > div:nth-child(3)");
  5. function init() {
  6. logBtn.on("click", () => {
  7. loginCheck();
  8. });
  9. id.on("keydown", (e) => {
  10. if (e.key === "Enter") {
  11. loginCheck();
  12. }
  13. });
  14. pwd.on("keydown", (e) => {
  15. if (e.key === "Enter") {
  16. loginCheck();
  17. }
  18. });
  19. logBtn.on("mouseenter", () => {
  20. $(".input-box > div:nth-child(3)> i:nth-child(1)").css("display", "none");
  21. $(".input-box > div:nth-child(3)> i:nth-child(2)").css("display", "block");
  22. logBtn.css({
  23. background: "#124c9b",
  24. border: "1px solid #124c9b",
  25. });
  26. });
  27. logBtn.on("mouseleave", () => {
  28. $(".input-box > div:nth-child(3)> i:nth-child(1)").css({ display: "block", top: "15px" });
  29. $(".input-box > div:nth-child(3)> i:nth-child(2)").css("display", "none");
  30. logBtn.css({
  31. background: "#1e65c5",
  32. border: "1px solid #1e65c5",
  33. });
  34. });
  35. }
  36. init();
  37. function nullChecker(checkItem) {
  38. return checkItem || null;
  39. }
  40. function loginCheck() {
  41. let idVal = $.trim(id.val());
  42. let pwdVal = $.trim(pwd.val());
  43. if (!nullChecker(idVal)) {
  44. alert("id를 입력해주세요");
  45. id.focus();
  46. return false;
  47. }
  48. if (!nullChecker(pwdVal)) {
  49. alert("비밀번호를 입력해주세요");
  50. pwd.focus();
  51. return false;
  52. }
  53. $("form").submit();
  54. }
  55. });