zh-CN.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*********************************
  2. * Themes, rules, and i18n support
  3. * Locale: Chinese; 中文
  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. ,qq: [/^[1-9]\d{4,}$/, "请填写有效的QQ号"]
  26. ,IDcard: [/^\d{6}(19|2\d)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)?$/, "请填写正确的身份证号码"]
  27. ,tel: [/^(?:(?:0\d{2,3}[\- ]?[1-9]\d{6,7})|(?:[48]00[\- ]?[1-9]\d{6}))$/, "请填写有效的电话号码"]
  28. ,mobile: [/^1[3-9]\d{9}$/, "请填写有效的手机号"]
  29. ,zipcode: [/^\d{6}$/, "请检查邮政编码格式"]
  30. ,chinese: [/^[\u0391-\uFFE5]+$/, "请填写中文字符"]
  31. ,username: [/^\w{3,12}$/, "请填写3-12位数字、字母、下划线"]
  32. ,password: [/^[\S]{6,16}$/, "请填写6-16位字符,不能包含空格"]
  33. ,accept: function (element, params){
  34. if (!params) return true;
  35. var ext = params[0],
  36. value = $(element).val();
  37. return (ext === '*') ||
  38. (new RegExp(".(?:" + ext + ")$", "i")).test(value) ||
  39. this.renderMsg("只接受{1}后缀的文件", ext.replace(/\|/g, ','));
  40. }
  41. },
  42. // Default error messages
  43. messages: {
  44. 0: "此处",
  45. fallback: "{0}格式不正确",
  46. loading: "正在验证...",
  47. error: "网络异常",
  48. timeout: "请求超时",
  49. required: "{0}不能为空",
  50. remote: "{0}已被使用",
  51. integer: {
  52. '*': "请填写整数",
  53. '+': "请填写正整数",
  54. '+0': "请填写正整数或0",
  55. '-': "请填写负整数",
  56. '-0': "请填写负整数或0"
  57. },
  58. match: {
  59. eq: "{0}与{1}不一致",
  60. neq: "{0}与{1}不能相同",
  61. lt: "{0}必须小于{1}",
  62. gt: "{0}必须大于{1}",
  63. lte: "{0}不能大于{1}",
  64. gte: "{0}不能小于{1}"
  65. },
  66. range: {
  67. rg: "请填写{1}到{2}的数",
  68. gte: "请填写不小于{1}的数",
  69. lte: "请填写最大{1}的数",
  70. gtlt: "请填写{1}到{2}之间的数",
  71. gt: "请填写大于{1}的数",
  72. lt: "请填写小于{1}的数"
  73. },
  74. checked: {
  75. eq: "请选择{1}项",
  76. rg: "请选择{1}到{2}项",
  77. gte: "请至少选择{1}项",
  78. lte: "请最多选择{1}项"
  79. },
  80. length: {
  81. eq: "请填写{1}个字符",
  82. rg: "请填写{1}到{2}个字符",
  83. gte: "请至少填写{1}个字符",
  84. lte: "请最多填写{1}个字符",
  85. eq_2: "",
  86. rg_2: "",
  87. gte_2: "",
  88. lte_2: ""
  89. }
  90. }
  91. });
  92. /* Themes
  93. */
  94. var TPL_ARROW = '<span class="n-arrow"><b>◆</b><i>◆</i></span>';
  95. $.validator.setTheme({
  96. 'simple_right': {
  97. formClass: 'n-simple',
  98. msgClass: 'n-right'
  99. },
  100. 'simple_bottom': {
  101. formClass: 'n-simple',
  102. msgClass: 'n-bottom'
  103. },
  104. 'yellow_top': {
  105. formClass: 'n-yellow',
  106. msgClass: 'n-top',
  107. msgArrow: TPL_ARROW
  108. },
  109. 'yellow_right': {
  110. formClass: 'n-yellow',
  111. msgClass: 'n-right',
  112. msgArrow: TPL_ARROW
  113. },
  114. 'yellow_right_effect': {
  115. formClass: 'n-yellow',
  116. msgClass: 'n-right',
  117. msgArrow: TPL_ARROW,
  118. msgShow: function($msgbox, type){
  119. var $el = $msgbox.children();
  120. if ($el.is(':animated')) return;
  121. if (type === 'error') {
  122. $el.css({left: '20px', opacity: 0})
  123. .delay(100).show().stop()
  124. .animate({left: '-4px', opacity: 1}, 150)
  125. .animate({left: '3px'}, 80)
  126. .animate({left: 0}, 80);
  127. } else {
  128. $el.css({left: 0, opacity: 1}).fadeIn(200);
  129. }
  130. },
  131. msgHide: function($msgbox, type){
  132. var $el = $msgbox.children();
  133. $el.stop().delay(100).show()
  134. .animate({left: '20px', opacity: 0}, 300, function(){
  135. $msgbox.hide();
  136. });
  137. }
  138. }
  139. });
  140. }));