You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.9 KiB

2 years ago
  1. $(function () {
  2. 'use strict';
  3. var sCusCommentsEmail = 'john.yuan@origtek-mail.com',
  4. sLang = $('[http-equiv="content-language"]').attr('content') || 'zh-TW',
  5. eForm = $("#footer-form"),
  6. /*
  7. * 目的 表單驗證初始化
  8. */
  9. fnSetForm_Rule = function () {
  10. eForm.validate({
  11. errorPlacement: function (error, element) {
  12. error.css({
  13. "border": "none",
  14. "color": "red"
  15. });
  16. var wrapper = $("<p></p>");
  17. error.appendTo(wrapper)
  18. $("#messageBox").append(wrapper);
  19. },
  20. highlight: function (element, errorClass) {
  21. $(element).css({
  22. "border": "1px solid red"
  23. });
  24. },
  25. unhighlight: function (element, errorClass) {
  26. $(element).css({
  27. "border": ""
  28. });
  29. },
  30. rules: {
  31. uname: {
  32. required: true
  33. },
  34. uemail: {
  35. email: true,
  36. required: true
  37. },
  38. utel: {
  39. required: true
  40. },
  41. umailcontent: {
  42. required: true
  43. },
  44. validcode: {
  45. required: true
  46. }
  47. },
  48. messages: {
  49. uname: {
  50. required: "請輸入聯絡人"
  51. },
  52. uemail: {
  53. email: "電子信箱格式錯誤",
  54. required: "請輸入電子信箱"
  55. },
  56. utel: {
  57. required: "請輸入聯絡電話"
  58. },
  59. umailcontent: {
  60. required: "請輸入內容"
  61. },
  62. validcode: {
  63. required: "請輸入驗證碼"
  64. }
  65. }
  66. });
  67. },
  68. /*
  69. * 目的 寄送郵件
  70. */
  71. fnSendMail = function () {
  72. if (!eForm.valid()) {
  73. return false;
  74. }
  75. var formdata = getFormSerialize(eForm);
  76. formdata.flag = 'cap2';
  77. formdata.type = 'C';
  78. return g_api.ConnectLite(Service.apiwebcom, 'SendMail', formdata, function (res) {
  79. if (res.RESULT) {
  80. if (res.DATA.rel) {
  81. showMsg(i18next.t("message.CusCommentsEmailSuccess"), 'success'); // 郵件已經寄出,我們將儘快為您處理。
  82. setTimeout(function () {
  83. location.reload();
  84. }, 3000);
  85. }
  86. else {
  87. showMsg(i18next.t("message.SendEmail_Failed"), 'error'); // 郵件寄送失敗
  88. $('#change_pic').click();
  89. }
  90. }
  91. else {
  92. showMsg(res.MSG, 'error'); // 驗證碼錯誤
  93. $('#change_pic').click();
  94. }
  95. }, function () {
  96. showMsg(i18next.t("message.SendEmail_Failed"), 'error'); // 郵件寄送失敗
  97. }, null, i18next.t('message.Dataprocessing'));
  98. },
  99. init = function () {
  100. fnSetForm_Rule();
  101. $("#sendmail").on("click", function () {
  102. fnSendMail();
  103. return false;
  104. });
  105. $('#change_pic').on('click', function () {
  106. $('#imgBtnCaptcha').attr('src', $('#imgBtnCaptcha').attr('src') + '?' + Math.random());
  107. });
  108. setLang(sLang);
  109. };
  110. init();
  111. });