zh-TW.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*********************************
  2. * Themes, rules, and i18n support
  3. * Locale: Chinese; 中文; TW (Taiwan)
  4. *********************************/
  5. (function(factory) {
  6. typeof module === "object" && module.exports ? module.exports = factory( require( "jquery" ) ) :
  7. typeof define === 'function' && define.amd ? define(['jquery'], factory) :
  8. factory(jQuery);
  9. }(function($) {
  10. /* Global configuration
  11. */
  12. $.validator.config({
  13. //stopOnError: true,
  14. //focusCleanup: true,
  15. //theme: 'yellow_right',
  16. //timely: 2,
  17. // Custom rules
  18. rules: {
  19. digits: [/^\d+$/, "請填寫數字"]
  20. ,letters: [/^[a-z]+$/i, "請填寫字母"]
  21. ,date: [/^\d{4}-\d{2}-\d{2}$/, "請填寫有效的日期,格式:yyyy-mm-dd"]
  22. ,time: [/^([01]\d|2[0-3])(:[0-5]\d){1,2}$/, "請填寫有效的時間,00:00到23:59之間"]
  23. ,email: [/^[\w\+\-]+(\.[\w\+\-]+)*@[a-z\d\-]+(\.[a-z\d\-]+)*\.([a-z]{2,4})$/i, "請填寫有效的電郵"]
  24. ,url: [/^(https?|s?ftp):\/\/\S+$/i, "請填寫有效的網址"]
  25. ,accept: function (element, params){
  26. if (!params) return true;
  27. var ext = params[0],
  28. value = $(element).val();
  29. return (ext === '*') ||
  30. (new RegExp(".(?:" + ext + ")$", "i")).test(value) ||
  31. this.renderMsg("只接受{1}後綴的文件", ext.replace(/\|/g, ','));
  32. }
  33. },
  34. // Default error messages
  35. messages: {
  36. 0: "此處",
  37. fallback: "{0}格式不正確",
  38. loading: "正在驗證...",
  39. error: "網絡異常",
  40. timeout: "請求超時",
  41. required: "{0}不能為空",
  42. remote: "{0}已被使用",
  43. integer: {
  44. '*': "請填寫整數",
  45. '+': "請填寫正整數",
  46. '+0': "請填寫正整數或0",
  47. '-': "請填寫負整數",
  48. '-0': "請填寫負整數或0"
  49. },
  50. match: {
  51. eq: "{0}與{1}不一致",
  52. neq: "{0}與{1}不能相同",
  53. lt: "{0}必須小於{1}",
  54. gt: "{0}必須大於{1}",
  55. lte: "{0}不能大於{1}",
  56. gte: "{0}不能小於{1}"
  57. },
  58. range: {
  59. rg: "請填寫{1}到{2}的數",
  60. gte: "請填寫不小於{1}的數",
  61. lte: "請填寫最大{1}的數",
  62. gtlt: "請填寫{1}到{2}之間的數",
  63. gt: "請填寫大於{1}的數",
  64. lt: "請填寫小於{1}的數"
  65. },
  66. checked: {
  67. eq: "請選擇{1}項",
  68. rg: "請選擇{1}到{2}項",
  69. gte: "請至少選擇{1}項",
  70. lte: "請最多選擇{1}項"
  71. },
  72. length: {
  73. eq: "請填寫{1}個字符",
  74. rg: "請填寫{1}到{2}個字符",
  75. gte: "請至少填寫{1}個字符",
  76. lte: "請最多填寫{1}個字符",
  77. eq_2: "",
  78. rg_2: "",
  79. gte_2: "",
  80. lte_2: ""
  81. }
  82. }
  83. });
  84. /* Themes
  85. */
  86. var TPL_ARROW = '<span class="n-arrow"><b>◆</b><i>◆</i></span>';
  87. $.validator.setTheme({
  88. 'simple_right': {
  89. formClass: 'n-simple',
  90. msgClass: 'n-right'
  91. },
  92. 'simple_bottom': {
  93. formClass: 'n-simple',
  94. msgClass: 'n-bottom'
  95. },
  96. 'yellow_top': {
  97. formClass: 'n-yellow',
  98. msgClass: 'n-top',
  99. msgArrow: TPL_ARROW
  100. },
  101. 'yellow_right': {
  102. formClass: 'n-yellow',
  103. msgClass: 'n-right',
  104. msgArrow: TPL_ARROW
  105. },
  106. 'yellow_right_effect': {
  107. formClass: 'n-yellow',
  108. msgClass: 'n-right',
  109. msgArrow: TPL_ARROW,
  110. msgShow: function($msgbox, type){
  111. var $el = $msgbox.children();
  112. if ($el.is(':animated')) return;
  113. if (type === 'error') {
  114. $el.css({left: '20px', opacity: 0})
  115. .delay(100).show().stop()
  116. .animate({left: '-4px', opacity: 1}, 150)
  117. .animate({left: '3px'}, 80)
  118. .animate({left: 0}, 80);
  119. } else {
  120. $el.css({left: 0, opacity: 1}).fadeIn(200);
  121. }
  122. },
  123. msgHide: function($msgbox, type){
  124. var $el = $msgbox.children();
  125. $el.stop().delay(100).show()
  126. .animate({left: '20px', opacity: 0}, 300, function(){
  127. $msgbox.hide();
  128. });
  129. }
  130. }
  131. });
  132. }));