jquery-validation_dist_additional-methods.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  1. import {
  2. require_jquery
  3. } from "./chunk-DH55I632.js";
  4. import {
  5. __commonJS
  6. } from "./chunk-WFTEJBJX.js";
  7. // node_modules/jquery-validation/dist/additional-methods.js
  8. var require_additional_methods = __commonJS({
  9. "node_modules/jquery-validation/dist/additional-methods.js"(exports, module) {
  10. (function(factory) {
  11. if (typeof define === "function" && define.amd) {
  12. define(["jquery", "./jquery.validate"], factory);
  13. } else if (typeof module === "object" && module.exports) {
  14. module.exports = factory(require_jquery());
  15. } else {
  16. factory(jQuery);
  17. }
  18. })(function($) {
  19. (function() {
  20. function stripHtml(value) {
  21. return value.replace(/<.[^<>]*?>/g, " ").replace(/&nbsp;|&#160;/gi, " ").replace(/[.(),;:!?%#$'\"_+=\/\-“”’]*/g, "");
  22. }
  23. $.validator.addMethod("maxWords", function(value, element, params) {
  24. return this.optional(element) || stripHtml(value).match(/\b\w+\b/g).length <= params;
  25. }, $.validator.format("Please enter {0} words or less."));
  26. $.validator.addMethod("minWords", function(value, element, params) {
  27. return this.optional(element) || stripHtml(value).match(/\b\w+\b/g).length >= params;
  28. }, $.validator.format("Please enter at least {0} words."));
  29. $.validator.addMethod("rangeWords", function(value, element, params) {
  30. var valueStripped = stripHtml(value), regex = /\b\w+\b/g;
  31. return this.optional(element) || valueStripped.match(regex).length >= params[0] && valueStripped.match(regex).length <= params[1];
  32. }, $.validator.format("Please enter between {0} and {1} words."));
  33. })();
  34. $.validator.addMethod("abaRoutingNumber", function(value) {
  35. var checksum = 0;
  36. var tokens = value.split("");
  37. var length = tokens.length;
  38. if (length !== 9) {
  39. return false;
  40. }
  41. for (var i = 0; i < length; i += 3) {
  42. checksum += parseInt(tokens[i], 10) * 3 + parseInt(tokens[i + 1], 10) * 7 + parseInt(tokens[i + 2], 10);
  43. }
  44. if (checksum !== 0 && checksum % 10 === 0) {
  45. return true;
  46. }
  47. return false;
  48. }, "Please enter a valid routing number.");
  49. $.validator.addMethod("accept", function(value, element, param) {
  50. var typeParam = typeof param === "string" ? param.replace(/\s/g, "") : "image/*", optionalValue = this.optional(element), i, file, regex;
  51. if (optionalValue) {
  52. return optionalValue;
  53. }
  54. if ($(element).attr("type") === "file") {
  55. typeParam = typeParam.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$\|]/g, "\\$&").replace(/,/g, "|").replace(/\/\*/g, "/.*");
  56. if (element.files && element.files.length) {
  57. regex = new RegExp(".?(" + typeParam + ")$", "i");
  58. for (i = 0; i < element.files.length; i++) {
  59. file = element.files[i];
  60. if (!file.type.match(regex)) {
  61. return false;
  62. }
  63. }
  64. }
  65. }
  66. return true;
  67. }, $.validator.format("Please enter a value with a valid mimetype."));
  68. $.validator.addMethod("alphanumeric", function(value, element) {
  69. return this.optional(element) || /^\w+$/i.test(value);
  70. }, "Letters, numbers, and underscores only please.");
  71. $.validator.addMethod("bankaccountNL", function(value, element) {
  72. if (this.optional(element)) {
  73. return true;
  74. }
  75. if (!/^[0-9]{9}|([0-9]{2} ){3}[0-9]{3}$/.test(value)) {
  76. return false;
  77. }
  78. var account = value.replace(/ /g, ""), sum = 0, len = account.length, pos, factor, digit;
  79. for (pos = 0; pos < len; pos++) {
  80. factor = len - pos;
  81. digit = account.substring(pos, pos + 1);
  82. sum = sum + factor * digit;
  83. }
  84. return sum % 11 === 0;
  85. }, "Please specify a valid bank account number.");
  86. $.validator.addMethod("bankorgiroaccountNL", function(value, element) {
  87. return this.optional(element) || $.validator.methods.bankaccountNL.call(this, value, element) || $.validator.methods.giroaccountNL.call(this, value, element);
  88. }, "Please specify a valid bank or giro account number.");
  89. $.validator.addMethod("bic", function(value, element) {
  90. return this.optional(element) || /^([A-Z]{6}[A-Z2-9][A-NP-Z1-9])(X{3}|[A-WY-Z0-9][A-Z0-9]{2})?$/.test(value.toUpperCase());
  91. }, "Please specify a valid BIC code.");
  92. $.validator.addMethod("cifES", function(value, element) {
  93. "use strict";
  94. if (this.optional(element)) {
  95. return true;
  96. }
  97. var cifRegEx = new RegExp(/^([ABCDEFGHJKLMNPQRSUVW])(\d{7})([0-9A-J])$/gi);
  98. var letter = value.substring(0, 1), number = value.substring(1, 8), control = value.substring(8, 9), all_sum = 0, even_sum = 0, odd_sum = 0, i, n, control_digit, control_letter;
  99. function isOdd(n2) {
  100. return n2 % 2 === 0;
  101. }
  102. if (value.length !== 9 || !cifRegEx.test(value)) {
  103. return false;
  104. }
  105. for (i = 0; i < number.length; i++) {
  106. n = parseInt(number[i], 10);
  107. if (isOdd(i)) {
  108. n *= 2;
  109. odd_sum += n < 10 ? n : n - 9;
  110. } else {
  111. even_sum += n;
  112. }
  113. }
  114. all_sum = even_sum + odd_sum;
  115. control_digit = (10 - all_sum.toString().substr(-1)).toString();
  116. control_digit = parseInt(control_digit, 10) > 9 ? "0" : control_digit;
  117. control_letter = "JABCDEFGHI".substr(control_digit, 1).toString();
  118. if (letter.match(/[ABEH]/)) {
  119. return control === control_digit;
  120. } else if (letter.match(/[KPQS]/)) {
  121. return control === control_letter;
  122. }
  123. return control === control_digit || control === control_letter;
  124. }, "Please specify a valid CIF number.");
  125. $.validator.addMethod("cnhBR", function(value) {
  126. value = value.replace(/([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g, "");
  127. if (value.length !== 11) {
  128. return false;
  129. }
  130. var sum = 0, dsc = 0, firstChar, firstCN, secondCN, i, j, v;
  131. firstChar = value.charAt(0);
  132. if (new Array(12).join(firstChar) === value) {
  133. return false;
  134. }
  135. for (i = 0, j = 9, v = 0; i < 9; ++i, --j) {
  136. sum += +(value.charAt(i) * j);
  137. }
  138. firstCN = sum % 11;
  139. if (firstCN >= 10) {
  140. firstCN = 0;
  141. dsc = 2;
  142. }
  143. sum = 0;
  144. for (i = 0, j = 1, v = 0; i < 9; ++i, ++j) {
  145. sum += +(value.charAt(i) * j);
  146. }
  147. secondCN = sum % 11;
  148. if (secondCN >= 10) {
  149. secondCN = 0;
  150. } else {
  151. secondCN = secondCN - dsc;
  152. }
  153. return String(firstCN).concat(secondCN) === value.substr(-2);
  154. }, "Please specify a valid CNH number.");
  155. $.validator.addMethod("cnpjBR", function(value, element) {
  156. "use strict";
  157. if (this.optional(element)) {
  158. return true;
  159. }
  160. value = value.replace(/[^\d]+/g, "");
  161. if (value.length !== 14) {
  162. return false;
  163. }
  164. if (value === "00000000000000" || value === "11111111111111" || value === "22222222222222" || value === "33333333333333" || value === "44444444444444" || value === "55555555555555" || value === "66666666666666" || value === "77777777777777" || value === "88888888888888" || value === "99999999999999") {
  165. return false;
  166. }
  167. var tamanho = value.length - 2;
  168. var numeros = value.substring(0, tamanho);
  169. var digitos = value.substring(tamanho);
  170. var soma = 0;
  171. var pos = tamanho - 7;
  172. for (var i = tamanho; i >= 1; i--) {
  173. soma += numeros.charAt(tamanho - i) * pos--;
  174. if (pos < 2) {
  175. pos = 9;
  176. }
  177. }
  178. var resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
  179. if (resultado !== parseInt(digitos.charAt(0), 10)) {
  180. return false;
  181. }
  182. tamanho = tamanho + 1;
  183. numeros = value.substring(0, tamanho);
  184. soma = 0;
  185. pos = tamanho - 7;
  186. for (var il = tamanho; il >= 1; il--) {
  187. soma += numeros.charAt(tamanho - il) * pos--;
  188. if (pos < 2) {
  189. pos = 9;
  190. }
  191. }
  192. resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
  193. if (resultado !== parseInt(digitos.charAt(1), 10)) {
  194. return false;
  195. }
  196. return true;
  197. }, "Please specify a CNPJ value number.");
  198. $.validator.addMethod("cpfBR", function(value, element) {
  199. "use strict";
  200. if (this.optional(element)) {
  201. return true;
  202. }
  203. value = value.replace(/([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g, "");
  204. if (value.length !== 11) {
  205. return false;
  206. }
  207. var sum = 0, firstCN, secondCN, checkResult, i;
  208. firstCN = parseInt(value.substring(9, 10), 10);
  209. secondCN = parseInt(value.substring(10, 11), 10);
  210. checkResult = function(sum2, cn) {
  211. var result = sum2 * 10 % 11;
  212. if (result === 10 || result === 11) {
  213. result = 0;
  214. }
  215. return result === cn;
  216. };
  217. if (value === "" || value === "00000000000" || value === "11111111111" || value === "22222222222" || value === "33333333333" || value === "44444444444" || value === "55555555555" || value === "66666666666" || value === "77777777777" || value === "88888888888" || value === "99999999999") {
  218. return false;
  219. }
  220. for (i = 1; i <= 9; i++) {
  221. sum = sum + parseInt(value.substring(i - 1, i), 10) * (11 - i);
  222. }
  223. if (checkResult(sum, firstCN)) {
  224. sum = 0;
  225. for (i = 1; i <= 10; i++) {
  226. sum = sum + parseInt(value.substring(i - 1, i), 10) * (12 - i);
  227. }
  228. return checkResult(sum, secondCN);
  229. }
  230. return false;
  231. }, "Please specify a valid CPF number.");
  232. $.validator.addMethod("creditcard", function(value, element) {
  233. if (this.optional(element)) {
  234. return "dependency-mismatch";
  235. }
  236. if (/[^0-9 \-]+/.test(value)) {
  237. return false;
  238. }
  239. var nCheck = 0, nDigit = 0, bEven = false, n, cDigit;
  240. value = value.replace(/\D/g, "");
  241. if (value.length < 13 || value.length > 19) {
  242. return false;
  243. }
  244. for (n = value.length - 1; n >= 0; n--) {
  245. cDigit = value.charAt(n);
  246. nDigit = parseInt(cDigit, 10);
  247. if (bEven) {
  248. if ((nDigit *= 2) > 9) {
  249. nDigit -= 9;
  250. }
  251. }
  252. nCheck += nDigit;
  253. bEven = !bEven;
  254. }
  255. return nCheck % 10 === 0;
  256. }, "Please enter a valid credit card number.");
  257. $.validator.addMethod("creditcardtypes", function(value, element, param) {
  258. if (/[^0-9\-]+/.test(value)) {
  259. return false;
  260. }
  261. value = value.replace(/\D/g, "");
  262. var validTypes = 0;
  263. if (param.mastercard) {
  264. validTypes |= 1;
  265. }
  266. if (param.visa) {
  267. validTypes |= 2;
  268. }
  269. if (param.amex) {
  270. validTypes |= 4;
  271. }
  272. if (param.dinersclub) {
  273. validTypes |= 8;
  274. }
  275. if (param.enroute) {
  276. validTypes |= 16;
  277. }
  278. if (param.discover) {
  279. validTypes |= 32;
  280. }
  281. if (param.jcb) {
  282. validTypes |= 64;
  283. }
  284. if (param.unknown) {
  285. validTypes |= 128;
  286. }
  287. if (param.all) {
  288. validTypes = 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128;
  289. }
  290. if (validTypes & 1 && (/^(5[12345])/.test(value) || /^(2[234567])/.test(value))) {
  291. return value.length === 16;
  292. }
  293. if (validTypes & 2 && /^(4)/.test(value)) {
  294. return value.length === 16;
  295. }
  296. if (validTypes & 4 && /^(3[47])/.test(value)) {
  297. return value.length === 15;
  298. }
  299. if (validTypes & 8 && /^(3(0[012345]|[68]))/.test(value)) {
  300. return value.length === 14;
  301. }
  302. if (validTypes & 16 && /^(2(014|149))/.test(value)) {
  303. return value.length === 15;
  304. }
  305. if (validTypes & 32 && /^(6011)/.test(value)) {
  306. return value.length === 16;
  307. }
  308. if (validTypes & 64 && /^(3)/.test(value)) {
  309. return value.length === 16;
  310. }
  311. if (validTypes & 64 && /^(2131|1800)/.test(value)) {
  312. return value.length === 15;
  313. }
  314. if (validTypes & 128) {
  315. return true;
  316. }
  317. return false;
  318. }, "Please enter a valid credit card number.");
  319. $.validator.addMethod("currency", function(value, element, param) {
  320. var isParamString = typeof param === "string", symbol = isParamString ? param : param[0], soft = isParamString ? true : param[1], regex;
  321. symbol = symbol.replace(/,/g, "");
  322. symbol = soft ? symbol + "]" : symbol + "]?";
  323. regex = "^[" + symbol + "([1-9]{1}[0-9]{0,2}(\\,[0-9]{3})*(\\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\\.[0-9]{0,2})?|0(\\.[0-9]{0,2})?|(\\.[0-9]{1,2})?)$";
  324. regex = new RegExp(regex);
  325. return this.optional(element) || regex.test(value);
  326. }, "Please specify a valid currency.");
  327. $.validator.addMethod("dateFA", function(value, element) {
  328. return this.optional(element) || /^[1-4]\d{3}\/((0?[1-6]\/((3[0-1])|([1-2][0-9])|(0?[1-9])))|((1[0-2]|(0?[7-9]))\/(30|([1-2][0-9])|(0?[1-9]))))$/.test(value);
  329. }, $.validator.messages.date);
  330. $.validator.addMethod("dateITA", function(value, element) {
  331. var check = false, re = /^\d{1,2}\/\d{1,2}\/\d{4}$/, adata, gg, mm, aaaa, xdata;
  332. if (re.test(value)) {
  333. adata = value.split("/");
  334. gg = parseInt(adata[0], 10);
  335. mm = parseInt(adata[1], 10);
  336. aaaa = parseInt(adata[2], 10);
  337. xdata = new Date(Date.UTC(aaaa, mm - 1, gg, 12, 0, 0, 0));
  338. if (xdata.getUTCFullYear() === aaaa && xdata.getUTCMonth() === mm - 1 && xdata.getUTCDate() === gg) {
  339. check = true;
  340. } else {
  341. check = false;
  342. }
  343. } else {
  344. check = false;
  345. }
  346. return this.optional(element) || check;
  347. }, $.validator.messages.date);
  348. $.validator.addMethod("dateNL", function(value, element) {
  349. return this.optional(element) || /^(0?[1-9]|[12]\d|3[01])[\.\/\-](0?[1-9]|1[012])[\.\/\-]([12]\d)?(\d\d)$/.test(value);
  350. }, $.validator.messages.date);
  351. $.validator.addMethod("extension", function(value, element, param) {
  352. param = typeof param === "string" ? param.replace(/,/g, "|") : "png|jpe?g|gif";
  353. return this.optional(element) || value.match(new RegExp("\\.(" + param + ")$", "i"));
  354. }, $.validator.format("Please enter a value with a valid extension."));
  355. $.validator.addMethod("giroaccountNL", function(value, element) {
  356. return this.optional(element) || /^[0-9]{1,7}$/.test(value);
  357. }, "Please specify a valid giro account number.");
  358. $.validator.addMethod("greaterThan", function(value, element, param) {
  359. var target = $(param);
  360. if (this.settings.onfocusout && target.not(".validate-greaterThan-blur").length) {
  361. target.addClass("validate-greaterThan-blur").on("blur.validate-greaterThan", function() {
  362. $(element).valid();
  363. });
  364. }
  365. return value > target.val();
  366. }, "Please enter a greater value.");
  367. $.validator.addMethod("greaterThanEqual", function(value, element, param) {
  368. var target = $(param);
  369. if (this.settings.onfocusout && target.not(".validate-greaterThanEqual-blur").length) {
  370. target.addClass("validate-greaterThanEqual-blur").on("blur.validate-greaterThanEqual", function() {
  371. $(element).valid();
  372. });
  373. }
  374. return value >= target.val();
  375. }, "Please enter a greater value.");
  376. $.validator.addMethod("iban", function(value, element) {
  377. if (this.optional(element)) {
  378. return true;
  379. }
  380. var iban = value.replace(/ /g, "").toUpperCase(), ibancheckdigits = "", leadingZeroes = true, cRest = "", cOperator = "", countrycode, ibancheck, charAt, cChar, bbanpattern, bbancountrypatterns, ibanregexp, i, p;
  381. var minimalIBANlength = 5;
  382. if (iban.length < minimalIBANlength) {
  383. return false;
  384. }
  385. countrycode = iban.substring(0, 2);
  386. bbancountrypatterns = {
  387. "AL": "\\d{8}[\\dA-Z]{16}",
  388. "AD": "\\d{8}[\\dA-Z]{12}",
  389. "AT": "\\d{16}",
  390. "AZ": "[\\dA-Z]{4}\\d{20}",
  391. "BE": "\\d{12}",
  392. "BH": "[A-Z]{4}[\\dA-Z]{14}",
  393. "BA": "\\d{16}",
  394. "BR": "\\d{23}[A-Z][\\dA-Z]",
  395. "BG": "[A-Z]{4}\\d{6}[\\dA-Z]{8}",
  396. "CR": "\\d{17}",
  397. "HR": "\\d{17}",
  398. "CY": "\\d{8}[\\dA-Z]{16}",
  399. "CZ": "\\d{20}",
  400. "DK": "\\d{14}",
  401. "DO": "[A-Z]{4}\\d{20}",
  402. "EE": "\\d{16}",
  403. "FO": "\\d{14}",
  404. "FI": "\\d{14}",
  405. "FR": "\\d{10}[\\dA-Z]{11}\\d{2}",
  406. "GE": "[\\dA-Z]{2}\\d{16}",
  407. "DE": "\\d{18}",
  408. "GI": "[A-Z]{4}[\\dA-Z]{15}",
  409. "GR": "\\d{7}[\\dA-Z]{16}",
  410. "GL": "\\d{14}",
  411. "GT": "[\\dA-Z]{4}[\\dA-Z]{20}",
  412. "HU": "\\d{24}",
  413. "IS": "\\d{22}",
  414. "IE": "[\\dA-Z]{4}\\d{14}",
  415. "IL": "\\d{19}",
  416. "IT": "[A-Z]\\d{10}[\\dA-Z]{12}",
  417. "KZ": "\\d{3}[\\dA-Z]{13}",
  418. "KW": "[A-Z]{4}[\\dA-Z]{22}",
  419. "LV": "[A-Z]{4}[\\dA-Z]{13}",
  420. "LB": "\\d{4}[\\dA-Z]{20}",
  421. "LI": "\\d{5}[\\dA-Z]{12}",
  422. "LT": "\\d{16}",
  423. "LU": "\\d{3}[\\dA-Z]{13}",
  424. "MK": "\\d{3}[\\dA-Z]{10}\\d{2}",
  425. "MT": "[A-Z]{4}\\d{5}[\\dA-Z]{18}",
  426. "MR": "\\d{23}",
  427. "MU": "[A-Z]{4}\\d{19}[A-Z]{3}",
  428. "MC": "\\d{10}[\\dA-Z]{11}\\d{2}",
  429. "MD": "[\\dA-Z]{2}\\d{18}",
  430. "ME": "\\d{18}",
  431. "NL": "[A-Z]{4}\\d{10}",
  432. "NO": "\\d{11}",
  433. "PK": "[\\dA-Z]{4}\\d{16}",
  434. "PS": "[\\dA-Z]{4}\\d{21}",
  435. "PL": "\\d{24}",
  436. "PT": "\\d{21}",
  437. "RO": "[A-Z]{4}[\\dA-Z]{16}",
  438. "SM": "[A-Z]\\d{10}[\\dA-Z]{12}",
  439. "SA": "\\d{2}[\\dA-Z]{18}",
  440. "RS": "\\d{18}",
  441. "SK": "\\d{20}",
  442. "SI": "\\d{15}",
  443. "ES": "\\d{20}",
  444. "SE": "\\d{20}",
  445. "CH": "\\d{5}[\\dA-Z]{12}",
  446. "TN": "\\d{20}",
  447. "TR": "\\d{5}[\\dA-Z]{17}",
  448. "AE": "\\d{3}\\d{16}",
  449. "GB": "[A-Z]{4}\\d{14}",
  450. "VG": "[\\dA-Z]{4}\\d{16}"
  451. };
  452. bbanpattern = bbancountrypatterns[countrycode];
  453. if (typeof bbanpattern !== "undefined") {
  454. ibanregexp = new RegExp("^[A-Z]{2}\\d{2}" + bbanpattern + "$", "");
  455. if (!ibanregexp.test(iban)) {
  456. return false;
  457. }
  458. }
  459. ibancheck = iban.substring(4, iban.length) + iban.substring(0, 4);
  460. for (i = 0; i < ibancheck.length; i++) {
  461. charAt = ibancheck.charAt(i);
  462. if (charAt !== "0") {
  463. leadingZeroes = false;
  464. }
  465. if (!leadingZeroes) {
  466. ibancheckdigits += "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(charAt);
  467. }
  468. }
  469. for (p = 0; p < ibancheckdigits.length; p++) {
  470. cChar = ibancheckdigits.charAt(p);
  471. cOperator = "" + cRest + cChar;
  472. cRest = cOperator % 97;
  473. }
  474. return cRest === 1;
  475. }, "Please specify a valid IBAN.");
  476. $.validator.addMethod("integer", function(value, element) {
  477. return this.optional(element) || /^-?\d+$/.test(value);
  478. }, "A positive or negative non-decimal number please.");
  479. $.validator.addMethod("ipv4", function(value, element) {
  480. return this.optional(element) || /^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$/i.test(value);
  481. }, "Please enter a valid IP v4 address.");
  482. $.validator.addMethod("ipv6", function(value, element) {
  483. return this.optional(element) || /^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/i.test(value);
  484. }, "Please enter a valid IP v6 address.");
  485. $.validator.addMethod("lessThan", function(value, element, param) {
  486. var target = $(param);
  487. if (this.settings.onfocusout && target.not(".validate-lessThan-blur").length) {
  488. target.addClass("validate-lessThan-blur").on("blur.validate-lessThan", function() {
  489. $(element).valid();
  490. });
  491. }
  492. return value < target.val();
  493. }, "Please enter a lesser value.");
  494. $.validator.addMethod("lessThanEqual", function(value, element, param) {
  495. var target = $(param);
  496. if (this.settings.onfocusout && target.not(".validate-lessThanEqual-blur").length) {
  497. target.addClass("validate-lessThanEqual-blur").on("blur.validate-lessThanEqual", function() {
  498. $(element).valid();
  499. });
  500. }
  501. return value <= target.val();
  502. }, "Please enter a lesser value.");
  503. $.validator.addMethod("lettersonly", function(value, element) {
  504. return this.optional(element) || /^[a-z]+$/i.test(value);
  505. }, "Letters only please.");
  506. $.validator.addMethod("letterswithbasicpunc", function(value, element) {
  507. return this.optional(element) || /^[a-z\-.,()'"\s]+$/i.test(value);
  508. }, "Letters or punctuation only please.");
  509. $.validator.addMethod("maxfiles", function(value, element, param) {
  510. if (this.optional(element)) {
  511. return true;
  512. }
  513. if ($(element).attr("type") === "file") {
  514. if (element.files && element.files.length > param) {
  515. return false;
  516. }
  517. }
  518. return true;
  519. }, $.validator.format("Please select no more than {0} files."));
  520. $.validator.addMethod("maxsize", function(value, element, param) {
  521. if (this.optional(element)) {
  522. return true;
  523. }
  524. if ($(element).attr("type") === "file") {
  525. if (element.files && element.files.length) {
  526. for (var i = 0; i < element.files.length; i++) {
  527. if (element.files[i].size > param) {
  528. return false;
  529. }
  530. }
  531. }
  532. }
  533. return true;
  534. }, $.validator.format("File size must not exceed {0} bytes each."));
  535. $.validator.addMethod("maxsizetotal", function(value, element, param) {
  536. if (this.optional(element)) {
  537. return true;
  538. }
  539. if ($(element).attr("type") === "file") {
  540. if (element.files && element.files.length) {
  541. var totalSize = 0;
  542. for (var i = 0; i < element.files.length; i++) {
  543. totalSize += element.files[i].size;
  544. if (totalSize > param) {
  545. return false;
  546. }
  547. }
  548. }
  549. }
  550. return true;
  551. }, $.validator.format("Total size of all files must not exceed {0} bytes."));
  552. $.validator.addMethod("mobileNL", function(value, element) {
  553. return this.optional(element) || /^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)6((\s|\s?\-\s?)?[0-9]){8}$/.test(value);
  554. }, "Please specify a valid mobile number.");
  555. $.validator.addMethod("mobileRU", function(phone_number, element) {
  556. var ruPhone_number = phone_number.replace(/\(|\)|\s+|-/g, "");
  557. return this.optional(element) || ruPhone_number.length > 9 && /^((\+7|7|8)+([0-9]){10})$/.test(ruPhone_number);
  558. }, "Please specify a valid mobile number.");
  559. $.validator.addMethod("mobileUK", function(phone_number, element) {
  560. phone_number = phone_number.replace(/\(|\)|\s+|-/g, "");
  561. return this.optional(element) || phone_number.length > 9 && phone_number.match(/^(?:(?:(?:00\s?|\+)44\s?|0)7(?:[1345789]\d{2}|624)\s?\d{3}\s?\d{3})$/);
  562. }, "Please specify a valid mobile number.");
  563. $.validator.addMethod("netmask", function(value, element) {
  564. return this.optional(element) || /^(254|252|248|240|224|192|128)\.0\.0\.0|255\.(254|252|248|240|224|192|128|0)\.0\.0|255\.255\.(254|252|248|240|224|192|128|0)\.0|255\.255\.255\.(254|252|248|240|224|192|128|0)/i.test(value);
  565. }, "Please enter a valid netmask.");
  566. $.validator.addMethod("nieES", function(value, element) {
  567. "use strict";
  568. if (this.optional(element)) {
  569. return true;
  570. }
  571. var nieRegEx = new RegExp(/^[MXYZ]{1}[0-9]{7,8}[TRWAGMYFPDXBNJZSQVHLCKET]{1}$/gi);
  572. var validChars = "TRWAGMYFPDXBNJZSQVHLCKET", letter = value.substr(value.length - 1).toUpperCase(), number;
  573. value = value.toString().toUpperCase();
  574. if (value.length > 10 || value.length < 9 || !nieRegEx.test(value)) {
  575. return false;
  576. }
  577. value = value.replace(/^[X]/, "0").replace(/^[Y]/, "1").replace(/^[Z]/, "2");
  578. number = value.length === 9 ? value.substr(0, 8) : value.substr(0, 9);
  579. return validChars.charAt(parseInt(number, 10) % 23) === letter;
  580. }, "Please specify a valid NIE number.");
  581. $.validator.addMethod("nifES", function(value, element) {
  582. "use strict";
  583. if (this.optional(element)) {
  584. return true;
  585. }
  586. value = value.toUpperCase();
  587. if (!value.match("((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)")) {
  588. return false;
  589. }
  590. if (/^[0-9]{8}[A-Z]{1}$/.test(value)) {
  591. return "TRWAGMYFPDXBNJZSQVHLCKE".charAt(value.substring(8, 0) % 23) === value.charAt(8);
  592. }
  593. if (/^[KLM]{1}/.test(value)) {
  594. return value[8] === "TRWAGMYFPDXBNJZSQVHLCKE".charAt(value.substring(8, 1) % 23);
  595. }
  596. return false;
  597. }, "Please specify a valid NIF number.");
  598. $.validator.addMethod("nipPL", function(value) {
  599. "use strict";
  600. value = value.replace(/[^0-9]/g, "");
  601. if (value.length !== 10) {
  602. return false;
  603. }
  604. var arrSteps = [6, 5, 7, 2, 3, 4, 5, 6, 7];
  605. var intSum = 0;
  606. for (var i = 0; i < 9; i++) {
  607. intSum += arrSteps[i] * value[i];
  608. }
  609. var int2 = intSum % 11;
  610. var intControlNr = int2 === 10 ? 0 : int2;
  611. return intControlNr === parseInt(value[9], 10);
  612. }, "Please specify a valid NIP number.");
  613. $.validator.addMethod("nisBR", function(value) {
  614. var number;
  615. var cn;
  616. var sum = 0;
  617. var dv;
  618. var count;
  619. var multiplier;
  620. value = value.replace(/([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g, "");
  621. if (value.length !== 11) {
  622. return false;
  623. }
  624. cn = parseInt(value.substring(10, 11), 10);
  625. number = parseInt(value.substring(0, 10), 10);
  626. for (count = 2; count < 12; count++) {
  627. multiplier = count;
  628. if (count === 10) {
  629. multiplier = 2;
  630. }
  631. if (count === 11) {
  632. multiplier = 3;
  633. }
  634. sum += number % 10 * multiplier;
  635. number = parseInt(number / 10, 10);
  636. }
  637. dv = sum % 11;
  638. if (dv > 1) {
  639. dv = 11 - dv;
  640. } else {
  641. dv = 0;
  642. }
  643. if (cn === dv) {
  644. return true;
  645. } else {
  646. return false;
  647. }
  648. }, "Please specify a valid NIS/PIS number.");
  649. $.validator.addMethod("notEqualTo", function(value, element, param) {
  650. return this.optional(element) || !$.validator.methods.equalTo.call(this, value, element, param);
  651. }, "Please enter a different value, values must not be the same.");
  652. $.validator.addMethod("nowhitespace", function(value, element) {
  653. return this.optional(element) || /^\S+$/i.test(value);
  654. }, "No white space please.");
  655. $.validator.addMethod("pattern", function(value, element, param) {
  656. if (this.optional(element)) {
  657. return true;
  658. }
  659. if (typeof param === "string") {
  660. param = new RegExp("^(?:" + param + ")$");
  661. }
  662. return param.test(value);
  663. }, "Invalid format.");
  664. $.validator.addMethod("phoneNL", function(value, element) {
  665. return this.optional(element) || /^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)[1-9]((\s|\s?\-\s?)?[0-9]){8}$/.test(value);
  666. }, "Please specify a valid phone number.");
  667. $.validator.addMethod("phonePL", function(phone_number, element) {
  668. phone_number = phone_number.replace(/\s+/g, "");
  669. var regexp = /^(?:(?:(?:\+|00)?48)|(?:\(\+?48\)))?(?:1[2-8]|2[2-69]|3[2-49]|4[1-68]|5[0-9]|6[0-35-9]|[7-8][1-9]|9[145])\d{7}$/;
  670. return this.optional(element) || regexp.test(phone_number);
  671. }, "Please specify a valid phone number.");
  672. $.validator.addMethod("phonesUK", function(phone_number, element) {
  673. phone_number = phone_number.replace(/\(|\)|\s+|-/g, "");
  674. return this.optional(element) || phone_number.length > 9 && phone_number.match(/^(?:(?:(?:00\s?|\+)44\s?|0)(?:1\d{8,9}|[23]\d{9}|7(?:[1345789]\d{8}|624\d{6})))$/);
  675. }, "Please specify a valid uk phone number.");
  676. $.validator.addMethod("phoneUK", function(phone_number, element) {
  677. phone_number = phone_number.replace(/\(|\)|\s+|-/g, "");
  678. return this.optional(element) || phone_number.length > 9 && phone_number.match(/^(?:(?:(?:00\s?|\+)44\s?)|(?:\(?0))(?:\d{2}\)?\s?\d{4}\s?\d{4}|\d{3}\)?\s?\d{3}\s?\d{3,4}|\d{4}\)?\s?(?:\d{5}|\d{3}\s?\d{3})|\d{5}\)?\s?\d{4,5})$/);
  679. }, "Please specify a valid phone number.");
  680. $.validator.addMethod("phoneUS", function(phone_number, element) {
  681. phone_number = phone_number.replace(/\s+/g, "");
  682. return this.optional(element) || phone_number.length > 9 && phone_number.match(/^(\+?1-?)?(\([2-9]([02-9]\d|1[02-9])\)|[2-9]([02-9]\d|1[02-9]))-?[2-9]\d{2}-?\d{4}$/);
  683. }, "Please specify a valid phone number.");
  684. $.validator.addMethod("postalcodeBR", function(cep_value, element) {
  685. return this.optional(element) || /^\d{2}.\d{3}-\d{3}?$|^\d{5}-?\d{3}?$/.test(cep_value);
  686. }, "Informe um CEP válido.");
  687. $.validator.addMethod("postalCodeCA", function(value, element) {
  688. return this.optional(element) || /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ] *\d[ABCEGHJKLMNPRSTVWXYZ]\d$/i.test(value);
  689. }, "Please specify a valid postal code.");
  690. $.validator.addMethod("postalcodeIT", function(value, element) {
  691. return this.optional(element) || /^\d{5}$/.test(value);
  692. }, "Please specify a valid postal code.");
  693. $.validator.addMethod("postalcodeNL", function(value, element) {
  694. return this.optional(element) || /^[1-9][0-9]{3}\s?[a-zA-Z]{2}$/.test(value);
  695. }, "Please specify a valid postal code.");
  696. $.validator.addMethod("postcodeUK", function(value, element) {
  697. return this.optional(element) || /^((([A-PR-UWYZ][0-9])|([A-PR-UWYZ][0-9][0-9])|([A-PR-UWYZ][A-HK-Y][0-9])|([A-PR-UWYZ][A-HK-Y][0-9][0-9])|([A-PR-UWYZ][0-9][A-HJKSTUW])|([A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRVWXY]))\s?([0-9][ABD-HJLNP-UW-Z]{2})|(GIR)\s?(0AA))$/i.test(value);
  698. }, "Please specify a valid UK postcode.");
  699. $.validator.addMethod("require_from_group", function(value, element, options) {
  700. var $fields = $(options[1], element.form), $fieldsFirst = $fields.eq(0), validator = $fieldsFirst.data("valid_req_grp") ? $fieldsFirst.data("valid_req_grp") : $.extend({}, this), isValid = $fields.filter(function() {
  701. return validator.elementValue(this);
  702. }).length >= options[0];
  703. $fieldsFirst.data("valid_req_grp", validator);
  704. if (!$(element).data("being_validated")) {
  705. $fields.data("being_validated", true);
  706. $fields.each(function() {
  707. validator.element(this);
  708. });
  709. $fields.data("being_validated", false);
  710. }
  711. return isValid;
  712. }, $.validator.format("Please fill at least {0} of these fields."));
  713. $.validator.addMethod("skip_or_fill_minimum", function(value, element, options) {
  714. var $fields = $(options[1], element.form), $fieldsFirst = $fields.eq(0), validator = $fieldsFirst.data("valid_skip") ? $fieldsFirst.data("valid_skip") : $.extend({}, this), numberFilled = $fields.filter(function() {
  715. return validator.elementValue(this);
  716. }).length, isValid = numberFilled === 0 || numberFilled >= options[0];
  717. $fieldsFirst.data("valid_skip", validator);
  718. if (!$(element).data("being_validated")) {
  719. $fields.data("being_validated", true);
  720. $fields.each(function() {
  721. validator.element(this);
  722. });
  723. $fields.data("being_validated", false);
  724. }
  725. return isValid;
  726. }, $.validator.format("Please either skip these fields or fill at least {0} of them."));
  727. $.validator.addMethod("stateUS", function(value, element, options) {
  728. var isDefault = typeof options === "undefined", caseSensitive = isDefault || typeof options.caseSensitive === "undefined" ? false : options.caseSensitive, includeTerritories = isDefault || typeof options.includeTerritories === "undefined" ? false : options.includeTerritories, includeMilitary = isDefault || typeof options.includeMilitary === "undefined" ? false : options.includeMilitary, regex;
  729. if (!includeTerritories && !includeMilitary) {
  730. regex = "^(A[KLRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])$";
  731. } else if (includeTerritories && includeMilitary) {
  732. regex = "^(A[AEKLPRSZ]|C[AOT]|D[CE]|FL|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEINOPST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])$";
  733. } else if (includeTerritories) {
  734. regex = "^(A[KLRSZ]|C[AOT]|D[CE]|FL|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEINOPST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])$";
  735. } else {
  736. regex = "^(A[AEKLPRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])$";
  737. }
  738. regex = caseSensitive ? new RegExp(regex) : new RegExp(regex, "i");
  739. return this.optional(element) || regex.test(value);
  740. }, "Please specify a valid state.");
  741. $.validator.addMethod("strippedminlength", function(value, element, param) {
  742. return $(value).text().length >= param;
  743. }, $.validator.format("Please enter at least {0} characters."));
  744. $.validator.addMethod("time", function(value, element) {
  745. return this.optional(element) || /^([01]\d|2[0-3]|[0-9])(:[0-5]\d){1,2}$/.test(value);
  746. }, "Please enter a valid time, between 00:00 and 23:59.");
  747. $.validator.addMethod("time12h", function(value, element) {
  748. return this.optional(element) || /^((0?[1-9]|1[012])(:[0-5]\d){1,2}(\ ?[AP]M))$/i.test(value);
  749. }, "Please enter a valid time in 12-hour am/pm format.");
  750. $.validator.addMethod("url2", function(value, element) {
  751. return this.optional(element) || /^(?:(?:(?:https?|ftp):)?\/\/)(?:(?:[^\]\[?\/<~#`!@$^&*()+=}|:";',>{ ]|%[0-9A-Fa-f]{2})+(?::(?:[^\]\[?\/<~#`!@$^&*()+=}|:";',>{ ]|%[0-9A-Fa-f]{2})*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?)|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff])|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62}\.)))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(value);
  752. }, $.validator.messages.url);
  753. $.validator.addMethod("vinUS", function(v) {
  754. if (v.length !== 17) {
  755. return false;
  756. }
  757. var LL = ["A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"], VL = [1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 7, 9, 2, 3, 4, 5, 6, 7, 8, 9], FL = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2], rs = 0, i, n, d, f, cd, cdv;
  758. for (i = 0; i < 17; i++) {
  759. f = FL[i];
  760. d = v.slice(i, i + 1);
  761. if (isNaN(d)) {
  762. d = d.toUpperCase();
  763. n = VL[LL.indexOf(d)];
  764. } else {
  765. n = parseInt(d, 10);
  766. }
  767. if (i === 8) {
  768. cdv = n;
  769. if (d === "X") {
  770. cdv = 10;
  771. }
  772. }
  773. rs += n * f;
  774. }
  775. cd = rs % 11;
  776. if (cd === cdv) {
  777. return true;
  778. }
  779. return false;
  780. }, "The specified vehicle identification number (VIN) is invalid.");
  781. $.validator.addMethod("zipcodeUS", function(value, element) {
  782. return this.optional(element) || /^\d{5}(-\d{4})?$/.test(value);
  783. }, "The specified US ZIP Code is invalid.");
  784. $.validator.addMethod("ziprange", function(value, element) {
  785. return this.optional(element) || /^90[2-5]\d\{2\}-\d{4}$/.test(value);
  786. }, "Your ZIP-code must be in the range 902xx-xxxx to 905xx-xxxx.");
  787. return $;
  788. });
  789. }
  790. });
  791. export default require_additional_methods();
  792. /*! Bundled license information:
  793. jquery-validation/dist/additional-methods.js:
  794. (*!
  795. * jQuery Validation Plugin v1.21.0
  796. *
  797. * https://jqueryvalidation.org/
  798. *
  799. * Copyright (c) 2024 Jörn Zaefferer
  800. * Released under the MIT license
  801. *)
  802. */
  803. //# sourceMappingURL=jquery-validation_dist_additional-methods.js.map