jquery.validationEngine-zh_CN.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. var host = '';
  2. (function($){
  3. $.fn.validationEngineLanguage = function(){
  4. };
  5. $.validationEngineLanguage = {
  6. newLang: function(){
  7. $.validationEngineLanguage.allRules = {
  8. "required": { // Add your regex rules here, you can take telephone as an example
  9. "regex": "none",
  10. "alertText": $(this).val(),
  11. "alertTextCheckboxMultiple": "* 请选择一个项目",
  12. "alertTextCheckboxe": "* 请选择一个选项",
  13. "alertTextDateRange": "* 日期范围不可空白"
  14. },
  15. "requiredInFunction": {
  16. "func": function(field, rules, i, options){
  17. return (field.val() == "test") ? true : false;
  18. },
  19. "alertText": "* Field must equal test"
  20. },
  21. "checkCpassword": {
  22. "func": function(field, rules, i, options){
  23. return (field.val() == $("#password").val()) ? true : false;
  24. },
  25. "alertText": "* 确认密码错误"
  26. },
  27. "dateRange": {
  28. "regex": "none",
  29. "alertText": "* 无效的 ",
  30. "alertText2": " 日期范围"
  31. },
  32. "dateTimeRange": {
  33. "regex": "none",
  34. "alertText": "* 无效的 ",
  35. "alertText2": " 时间范围"
  36. },
  37. "minSize": {
  38. "regex": "none",
  39. "alertText": "* 密码要求:6~32个字符,至少包含数字和字母 ",
  40. "alertText2": ""
  41. },
  42. "maxSize": {
  43. "regex": "none",
  44. "alertText": "* 密码要求:6~32个字符,至少包含数字和字母 ",
  45. "alertText2": ""
  46. },
  47. "groupRequired": {
  48. "regex": "none",
  49. "alertText": "* 你必需选填其中一个栏位"
  50. },
  51. "min": {
  52. "regex": "none",
  53. "alertText": "* 最小值為 "
  54. },
  55. "max": {
  56. "regex": "none",
  57. "alertText": "* 最大值为 "
  58. },
  59. "past": {
  60. "regex": "none",
  61. "alertText": "* 日期必需早于 "
  62. },
  63. "future": {
  64. "regex": "none",
  65. "alertText": "* 日期必需晚于 "
  66. },
  67. "maxCheckbox": {
  68. "regex": "none",
  69. "alertText": "* 最多选取 ",
  70. "alertText2": " 个项目"
  71. },
  72. "minCheckbox": {
  73. "regex": "none",
  74. "alertText": "* 请选择 ",
  75. "alertText2": " 个项目"
  76. },
  77. "equals": {
  78. "regex": "none",
  79. "alertText": "* 请输入与上面相同的密码"
  80. },
  81. "creditCard": {
  82. "regex": "none",
  83. "alertText": "* 无效的信用卡号码"
  84. },
  85. "phone": {
  86. // credit: jquery.h5validate.js / orefalo
  87. "regex": /^0?1[3|4|5|8][0-9]\d{8}$/,
  88. "alertText": "* 无效手机号码"
  89. },
  90. "email": {
  91. // Shamelessly lifted from Scott Gonzalez via the Bassistance Validation plugin http://projects.scottsplayground.com/email_address_validation/
  92. "regex": /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,
  93. "alertText": "* 邮件地址无效"
  94. },
  95. "integer": {
  96. "regex": /^[\-\+]?\d+$/,
  97. "alertText": "* 不是有效的整数"
  98. },
  99. "number": {
  100. // Number, including positive, negative, and floating decimal. credit: orefalo
  101. "regex": /^[\-\+]?((([0-9]{1,3})([,][0-9]{3})*)|([0-9]+))?([\.]([0-9]+))?$/,
  102. "alertText": "* 无效的数字"
  103. },
  104. "date": {
  105. "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/,
  106. "alertText": "* 无效的日期,格式必需为 YYYY-MM-DD"
  107. },
  108. "ipv4": {
  109. "regex": /^((([01]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))[.]){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/,
  110. "alertText": "* 无效的 IP 地址"
  111. },
  112. "url": {
  113. "regex": /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,
  114. "alertText": "* Invalid URL"
  115. },
  116. "onlyNumberSp": {
  117. "regex": /^[0-9\ ]+$/,
  118. "alertText": "* 只能填数字"
  119. },
  120. "onlyTypeSp": {
  121. "regex": /^[1-9\ ]+$/,
  122. "alertText": "* 请选择类型"
  123. },
  124. "onlyAddressSp": {
  125. "regex": /^[1-9\ ]+$/,
  126. "alertText": "* 请选择地点"
  127. },
  128. "onlyLetterSp": {
  129. "regex": /^[a-zA-Z\ \']+$/,
  130. "alertText": "* 只接受英文字母大小写"
  131. },
  132. "onlyLetterNumber": {
  133. "regex": /^[0-9a-zA-Z_]+$/,
  134. "alertText": "* 不接受特殊字符"
  135. },
  136. "username":
  137. {
  138. "regex": /^[a-zA-Z0-9_]{1,15}|^[\u4e00-\u9fa5][a-zA-Z0-9\u4e00-\u9fa5_]{0,8}$/ ,
  139. "alertText": "* 建议1~8个汉字或3~15个字母数字"
  140. },
  141. "password":
  142. {
  143. "regex": /^[a-zA-Z0-9_]{6,32}$/,
  144. "alertText": "* 密码要求:6~32个字符,至少包含数字和字母"
  145. },
  146. // --- CUSTOM RULES -- Those are specific to the demos, they can be removed or changed to your likings
  147. "ajaxUserCall": {
  148. "url": "ajaxValidateFieldUser",
  149. // you may want to pass extra data on the ajax call
  150. "extraData": "name=eric",
  151. "alertText": "* 此名称已被其他人使用",
  152. "alertTextLoad": "* 正在确认名称是否有其他人使用,请稍等。"
  153. },
  154. "ajaxAddressCallPhp": {
  155. "url": "?_check=true&type=name",
  156. // you may want to pass extra data on the ajax call
  157. "extraData": "name=valid",
  158. // if you provide an "alertTextOk", it will show as a green prompt when the field validates
  159. "alertTextOk": "* 此名称可以使用",
  160. "alertText": "* 此地点已经使用",
  161. "alertTextLoad": "* 正在确认地点名称是否已经存在,请稍等。"
  162. },
  163. "ajaxEmailCallPhp": {
  164. "url": host + "check",
  165. // you may want to pass extra data on the ajax call
  166. "extraData": "type=email",
  167. // if you provide an "alertTextOk", it will show as a green prompt when the field validates
  168. "alertTextOk": "* 此邮箱可以使用",
  169. "alertText": "* 此邮箱已被其他人使用",
  170. "alertTextLoad": "* 正在确认邮箱是否有其他人使用,请稍等。"
  171. },
  172. "ajaxCodeCallPhp": {
  173. "url": host + "check",
  174. // you may want to pass extra data on the ajax call
  175. "extraData": "type=code",
  176. // if you provide an "alertTextOk", it will show as a green prompt when the field validates
  177. "alertTextOk": "* 验证码正确",
  178. "alertText": "* 验证码错误",
  179. "alertTextLoad": "* 正在确认验证码是否正确,请稍等。"
  180. },
  181. "ajaxUsernameCallPhp": {
  182. "url": host + "check",
  183. // you may want to pass extra data on the ajax call
  184. "extraData": "type=username",
  185. // if you provide an "alertTextOk", it will show as a green prompt when the field validates
  186. "alertTextOk": "* 昵称正确",
  187. "alertText": "* 昵称已被其他人使用",
  188. "alertTextLoad": "* 正在确认昵称是否可以使用,请稍等。"
  189. },
  190. "ajaxNameCall": {
  191. // remote json service location
  192. "url": "ajaxValidateFieldName",
  193. // error
  194. "alertText": "* 此名称可以使用",
  195. // if you provide an "alertTextOk", it will show as a green prompt when the field validates
  196. "alertTextOk": "* 此名称已被其他人使用",
  197. // speaks by itself
  198. "alertTextLoad": "* 正在确认名称是否有其他人使用,请稍等。"
  199. },
  200. "ajaxNameCallPhp": {
  201. // remote json service location
  202. "url": "phpajax/ajaxValidateFieldName.php",
  203. // error
  204. "alertText": "* 此名称已被其他人使用",
  205. // speaks by itself
  206. "alertTextLoad": "* 正在确认名称是否有其他人使用,请稍等。"
  207. },
  208. "validate2fields": {
  209. "alertText": "* 请输入 HELLO"
  210. },
  211. //tls warning:homegrown not fielded
  212. "dateFormat":{
  213. "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(?:(?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(0?2(\/|-)29)(\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$/,
  214. "alertText": "* 无效的日期格式"
  215. },
  216. //tls warning:homegrown not fielded
  217. "dateTimeFormat": {
  218. "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1}$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^((1[012]|0?[1-9]){1}\/(0?[1-9]|[12][0-9]|3[01]){1}\/\d{2,4}\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1})$/,
  219. "alertText": "* 无效的日期或时间格式",
  220. "alertText2": "可接受的格式: ",
  221. "alertText3": "mm/dd/yyyy hh:mm:ss AM|PM 或 ",
  222. "alertText4": "yyyy-mm-dd hh:mm:ss AM|PM"
  223. }
  224. };
  225. }
  226. };
  227. $.validationEngineLanguage.newLang();
  228. })(jQuery);