zh_CN.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*********************************
  2. * Themes, rules, and i18n support
  3. * Locale: Chinese; 中文
  4. *********************************/
  5. (function(factory) {
  6. if (typeof define === 'function') {
  7. define(function(require, exports, module){
  8. var $ = require('jquery');
  9. $._VALIDATOR_URI = module.uri;
  10. require('../src/jquery.validator')($);
  11. factory($);
  12. });
  13. } else {
  14. factory(jQuery);
  15. }
  16. }(function($) {
  17. /* Global configuration
  18. */
  19. $.validator.config({
  20. //stopOnError: false,
  21. //theme: 'yellow_right',
  22. defaultMsg: "{0}格式不正确",
  23. loadingMsg: "正在验证...",
  24. // Custom rules
  25. rules: {
  26. digits: [/^\d+$/, "请输入数字"]
  27. ,letters: [/^[a-z]+$/i, "{0}只能输入字母"]
  28. ,tel: [/^(?:(?:0\d{2,3}[\- ]?[1-9]\d{6,7})|(?:[48]00[\- ]?[1-9]\d{6}))$/, "电话格式不正确"]
  29. ,mobile: [/^1[3-9]\d{9}$/, "手机号格式不正确"]
  30. ,email: [/^[\w\+\-]+(\.[\w\+\-]+)*@[a-z\d\-]+(\.[a-z\d\-]+)*\.([a-z]{2,4})$/i, "邮箱格式不正确"]
  31. ,qq: [/^[1-9]\d{4,}$/, "QQ号格式不正确"]
  32. ,date: [/^\d{4}-\d{1,2}-\d{1,2}$/, "请输入正确的日期,例:yyyy-mm-dd"]
  33. ,time: [/^([01]\d|2[0-3])(:[0-5]\d){1,2}$/, "请输入正确的时间,例:14:30或14:30:00"]
  34. ,ID_card: [/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[A-Z])$/, "请输入正确的身份证号码"]
  35. ,url: [/^(https?|ftp):\/\/[^\s]+$/i, "网址格式不正确"]
  36. ,postcode: [/^[1-9]\d{5}$/, "邮政编码格式不正确"]
  37. ,chinese: [/^[\u0391-\uFFE5]+$/, "请输入中文"]
  38. ,username: [/^\w{3,12}$/, "请输入3-12位数字、字母、下划线"]
  39. ,password: [/^[0-9a-zA-Z]{6,16}$/, "密码由6-16位数字、字母组成"]
  40. ,accept: function (element, params){
  41. if (!params) return true;
  42. var ext = params[0];
  43. return (ext === '*') ||
  44. (new RegExp(".(?:" + (ext || "png|jpg|jpeg|gif") + ")$", "i")).test(element.value) ||
  45. this.renderMsg("只接受{1}后缀", ext.replace('|', ','));
  46. }
  47. }
  48. });
  49. /* Default error messages
  50. */
  51. $.validator.config({
  52. messages: {
  53. required: "{0}不能为空",
  54. remote: "{0}已被使用",
  55. integer: {
  56. '*': "请输入整数",
  57. '+': "请输入正整数",
  58. '+0': "请输入正整数或0",
  59. '-': "请输入负整数",
  60. '-0': "请输入负整数或0"
  61. },
  62. match: {
  63. eq: "{0}与{1}不一致",
  64. neq: "{0}与{1}不能相同",
  65. lt: "{0}必须小于{1}",
  66. gt: "{0}必须大于{1}",
  67. lte: "{0}必须小于或等于{1}",
  68. gte: "{0}必须大于或等于{1}"
  69. },
  70. range: {
  71. rg: "请输入{1}到{2}的数",
  72. gte: "请输入大于或等于{1}的数",
  73. lte: "请输入小于或等于{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({
  124. left: '20px',
  125. opacity: 0
  126. }).delay(100).show().stop().animate({
  127. left: '-4px',
  128. opacity: 1
  129. }, 150).animate({
  130. left: '3px'
  131. }, 80).animate({
  132. left: 0
  133. }, 80);
  134. } else {
  135. $el.css({
  136. left: 0,
  137. opacity: 1
  138. }).fadeIn(200);
  139. }
  140. },
  141. msgHide: function($msgbox, type){
  142. var $el = $msgbox.children();
  143. $el.stop().delay(100).show().animate({
  144. left: '20px',
  145. opacity: 0
  146. }, 300, function(){
  147. $msgbox.hide();
  148. });
  149. }
  150. }
  151. });
  152. }));