zh-CN.js 5.6 KB

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