vendor: 14,963 bytes, lines 1-446
1/*! 2 * jQuery Validation Plugin v1.19.5 3 * 4 * https://jqueryvalidation.org/ 5 * 6 * Copyright (c) 2022 Jörn Zaefferer 7 * Released under the MIT license 8 */ 9(function (factory) { 10 if (typeof define === "function" && define.amd) { 11 define(["jquery"], factory); 12 } else if (typeof module === "object" && module.exports) { 13 module.exports = factory(require("jquery")); 14 } else { 15 factory(jQuery); 16 } 17})(function ($) { 18 $.extend($.fn, { 19 validate: function (options) { 20 if (!this.length) { 21 if (options && options.debug && window.console) { 22 console.warn("Nothing selected, can't validate, returning nothing."); 23 } 24 return; 25 } 26 var validator = $.data(this[0], "validator"); 27 if (validator) { 28 return validator; 29 } 30 this.attr("novalidate", "novalidate"); 31 validator = new $.validator(options, this[0]); 32 $.data(this[0], "validator", validator); 33 if (validator.settings.onsubmit) { 34 this.on("click.validate", ":submit", function (event) { 35 validator.submitButton = event.currentTarget; 36 if ($(this).hasClass("cancel")) { 37 validator.cancelSubmit = !0; 38 } 39 if ($(this).attr("formnovalidate") !== undefined) { 40 validator.cancelSubmit = !0; 41 } 42 }); 43 this.on("submit.validate", function (event) { 44 if (validator.settings.debug) { 45 event.preventDefault(); 46 } 47 function handle() { 48 var hidden, result; 49 if ( 50 validator.submitButton && 51 (validator.settings.submitHandler || validator.formSubmitted) 52 ) { 53 hidden = $("<input type='hidden'>") 54 .attr("name", validator.submitButton.name) 55 .val($(validator.submitButton).val()) 56 .appendTo(validator.currentForm); 57 } 58 if (validator.settings.submitHandler && !validator.settings.debug) { 59 result = validator.settings.submitHandler.call( 60 validator, 61 validator.currentForm, 62 event 63 ); 64 if (hidden) { 65 hidden.remove(); 66 } 67 if (result !== undefined) { 68 return result; 69 } 70 return !1; 71 } 72 return !0; 73 } 74 if (validator.cancelSubmit) { 75 validator.cancelSubmit = !1; 76 return handle(); 77 } 78 if (validator.form()) { 79 if (validator.pendingRequest) { 80 validator.formSubmitted = !0; 81 return !1; 82 } 83 return handle(); 84 } else { 85 validator.focusInvalid(); 86 return !1; 87 } 88 }); 89 } 90 return validator; 91 }, 92 valid: function () { 93 var valid, validator, errorList; 94 if ($(this[0]).is("form")) { 95 valid = this.validate().form(); 96 } else { 97 errorList = []; 98 valid = !0; 99 validator = $(this[0].form).validate(); 100 this.each(function () { 101 valid = validator.element(this) && valid; 102 if (!valid) { 103 errorList = errorList.concat(validator.errorList); 104 } 105 }); 106 validator.errorList = errorList; 107 } 108 return valid; 109 }, 110 rules: function (command, argument) { 111 var element = this[0], 112 isContentEditable = 113 typeof this.attr("contenteditable") !== "undefined" && 114 this.attr("contenteditable") !== "false", 115 settings, 116 staticRules, 117 existingRules, 118 data, 119 param, 120 filtered; 121 if (element == null) { 122 return; 123 } 124 if (!element.form && isContentEditable) { 125 element.form = this.closest("form")[0]; 126 element.name = this.attr("name"); 127 } 128 if (element.form == null) { 129 return; 130 } 131 if (command) { 132 settings = $.data(element.form, "validator").settings; 133 staticRules = settings.rules; 134 existingRules = $.validator.staticRules(element); 135 switch (command) { 136 case "add": 137 $.extend(existingRules, $.validator.normalizeRule(argument)); 138 delete existingRules.messages; 139 staticRules[element.name] = existingRules; 140 if (argument.messages) { 141 settings.messages[element.name] = $.extend( 142 settings.messages[element.name], 143 argument.messages 144 ); 145 } 146 break; 147 case "remove": 148 if (!argument) { 149 delete staticRules[element.name]; 150 return existingRules; 151 } 152 filtered = {}; 153 $.each(argument.split(/\s/), function (index, method) { 154 filtered[method] = existingRules[method]; 155 delete existingRules[method]; 156 }); 157 return filtered; 158 } 159 } 160 data = $.validator.normalizeRules( 161 $.extend( 162 {}, 163 $.validator.classRules(element), 164 $.validator.attributeRules(element), 165 $.validator.dataRules(element), 166 $.validator.staticRules(element) 167 ), 168 element 169 ); 170 if (data.required) { 171 param = data.required; 172 delete data.required; 173 data = $.extend({ required: param }, data); 174 } 175 if (data.remote) { 176 param = data.remote; 177 delete data.remote; 178 data = $.extend(data, { remote: param }); 179 } 180 return data; 181 }, 182 }); 183 var trim = function (str) { 184 return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""); 185 }; 186 $.extend($.expr.pseudos || $.expr[":"], { 187 blank: function (a) { 188 return !trim("" + $(a).val()); 189 }, 190 filled: function (a) { 191 var val = $(a).val(); 192 return val !== null && !!trim("" + val); 193 }, 194 unchecked: function (a) { 195 return !$(a).prop("checked"); 196 }, 197 }); 198 $.validator = function (options, form) { 199 this.settings = $.extend(!0, {}, $.validator.defaults, options); 200 this.currentForm = form; 201 this.init(); 202 }; 203 $.validator.format = function (source, params) { 204 if (arguments.length === 1) { 205 return function () { 206 var args = $.makeArray(arguments); 207 args.unshift(source); 208 return $.validator.format.apply(this, args); 209 }; 210 } 211 if (params === undefined) { 212 return source; 213 } 214 if (arguments.length > 2 && params.constructor !== Array) { 215 params = $.makeArray(arguments).slice(1); 216 } 217 if (params.constructor !== Array) { 218 params = [params]; 219 } 220 $.each(params, function (i, n) { 221 source = source.replace(new RegExp("\\{" + i + "\\}", "g"), function () { 222 return n; 223 }); 224 }); 225 return source; 226 }; 227 $.extend($.validator, { 228 defaults: { 229 messages: {}, 230 groups: {}, 231 rules: {}, 232 errorClass: "error", 233 pendingClass: "pending", 234 validClass: "valid", 235 errorElement: "label", 236 focusCleanup: !1, 237 focusInvalid: !0, 238 errorContainer: $([]), 239 errorLabelContainer: $([]), 240 onsubmit: !0, 241 ignore: ":hidden", 242 ignoreTitle: !1, 243 onfocusin: function (element) { 244 this.lastActive = element; 245 if (this.settings.focusCleanup) { 246 if (this.settings.unhighlight) { 247 this.settings.unhighlight.call( 248 this, 249 element, 250 this.settings.errorClass, 251 this.settings.validClass 252 ); 253 } 254 this.hideThese(this.errorsFor(element)); 255 } 256 }, 257 onfocusout: function (element) { 258 if ( 259 !this.checkable(element) && 260 (element.name in this.submitted || !this.optional(element)) 261 ) { 262 this.element(element); 263 } 264 }, 265 onkeyup: function (element, event) { 266 var excludedKeys = [ 267 16, 17, 18, 20, 35, 36, 37, 38, 39, 40, 45, 144, 225, 268 ]; 269 if ( 270 (event.which === 9 && this.elementValue(element) === "") || 271 $.inArray(event.keyCode, excludedKeys) !== -1 272 ) { 273 return; 274 } else if ( 275 element.name in this.submitted || 276 element.name in this.invalid 277 ) { 278 this.element(element); 279 } 280 }, 281 onclick: function (element) { 282 if (element.name in this.submitted) { 283 this.element(element); 284 } else if (element.parentNode.name in this.submitted) { 285 this.element(element.parentNode); 286 } 287 }, 288 highlight: function (element, errorClass, validClass) { 289 if (element.type === "radio") { 290 this.findByName(element.name) 291 .addClass(errorClass) 292 .removeClass(validClass); 293 } else { 294 $(element).addClass(errorClass).removeClass(validClass); 295 } 296 }, 297 unhighlight: function (element, errorClass, validClass) { 298 if (element.type === "radio") { 299 this.findByName(element.name) 300 .removeClass(errorClass) 301 .addClass(validClass); 302 } else { 303 $(element).removeClass(errorClass).addClass(validClass); 304 } 305 }, 306 }, 307 setDefaults: function (settings) { 308 $.extend($.validator.defaults, settings); 309 }, 310 messages: { 311 required: "This field is required.", 312 remote: "Please fix this field.", 313 email: "Please enter a valid email address.", 314 url: "Please enter a valid URL.", 315 date: "Please enter a valid date.", 316 dateISO: "Please enter a valid date (ISO).", 317 number: "Please enter a valid number.", 318 digits: "Please enter only digits.", 319 equalTo: "Please enter the same value again.", 320 maxlength: $.validator.format( 321 "Please enter no more than {0} characters." 322 ), 323 minlength: $.validator.format("Please enter at least {0} characters."), 324 rangelength: $.validator.format( 325 "Please enter a value between {0} and {1} characters long." 326 ), 327 range: $.validator.format("Please enter a value between {0} and {1}."), 328 max: $.validator.format( 329 "Please enter a value less than or equal to {0}." 330 ), 331 min: $.validator.format( 332 "Please enter a value greater than or equal to {0}." 333 ), 334 step: $.validator.format("Please enter a multiple of {0}."), 335 }, 336 autoCreateRanges: !1, 337 prototype: { 338 init: function () { 339 this.labelContainer = $(this.settings.errorLabelContainer); 340 this.errorContext = 341 (this.labelContainer.length && this.labelContainer) || 342 $(this.currentForm); 343 this.containers = $(this.settings.errorContainer).add( 344 this.settings.errorLabelContainer 345 ); 346 this.submitted = {}; 347 this.valueCache = {}; 348 this.pendingRequest = 0; 349 this.pending = {}; 350 this.invalid = {}; 351 this.reset(); 352 var currentForm = this.currentForm, 353 groups = (this.groups = {}), 354 rules; 355 $.each(this.settings.groups, function (key, value) { 356 if (typeof value === "string") { 357 value = value.split(/\s/); 358 } 359 $.each(value, function (index, name) { 360 groups[name] = key; 361 }); 362 }); 363 rules = this.settings.rules; 364 $.each(rules, function (key, value) { 365 rules[key] = $.validator.normalizeRule(value); 366 }); 367 function delegate(event) { 368 var isContentEditable = 369 typeof $(this).attr("contenteditable") !== "undefined" && 370 $(this).attr("contenteditable") !== "false"; 371 if (!this.form && isContentEditable) { 372 this.form = $(this).closest("form")[0]; 373 this.name = $(this).attr("name"); 374 } 375 if (currentForm !== this.form) { 376 return; 377 } 378 var validator = $.data(this.form, "validator"), 379 eventType = "on" + event.type.replace(/^validate/, ""), 380 settings = validator.settings; 381 if (settings[eventType] && !$(this).is(settings.ignore)) { 382 settings[eventType].call(validator, this, event); 383 } 384 } 385 $(this.currentForm) 386 .on( 387 "focusin.validate focusout.validate keyup.validate", 388 ":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], " + 389 "[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], " + 390 "[type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], " + 391 "[type='radio'], [type='checkbox'], [contenteditable], [type='button']", 392 delegate 393 ) 394 .on( 395 "click.validate", 396 "select, option, [type='radio'], [type='checkbox']", 397 delegate 398 ); 399 if (this.settings.invalidHandler) { 400 $(this.currentForm).on( 401 "invalid-form.validate", 402 this.settings.invalidHandler 403 ); 404 } 405 }, 406 form: function () { 407 this.checkForm(); 408 $.extend(this.submitted, this.errorMap); 409 this.invalid = $.extend({}, this.errorMap); 410 if (!this.valid()) { 411 $(this.currentForm).triggerHandler("invalid-form", [this]); 412 } 413 this.showErrors(); 414 return this.valid(); 415 }, 416 checkForm: function () { 417 this.prepareForm(); 418 for ( 419 var i = 0, elements = (this.currentElements = this.elements()); 420 elements[i]; 421 i++ 422 ) { 423 this.check(elements[i]); 424 } 425 return this.valid(); 426 }, 427 element: function (element) { 428 var cleanElement = this.clean(element), 429 checkElement = this.validationTargetFor(cleanElement), 430 v = this, 431 result = !0, 432 rs, 433 group; 434 if (checkElement === undefined) { 435 delete this.invalid[cleanElement.name]; 436 } else { 437 this.prepareElement(checkElement); 438 this.currentElements = $(checkElement); 439 group = this.groups[checkElement.name]; 440 if (group) { 441 $.each(this.groups, function (name, testgroup) { 442 if (testgroup === group && name !== checkElement.name) { 443 cleanElement = v.validationTargetFor( 444 v.clean(v.findByName(name)) 445 ); 446 if (cleanElement && cleanElement.name in v.invali
446d) { 447 v.currentElements.push(cleanElement); 448 result = v.check(cleanElement) && result; 449 } 450 } 451 }); 452 } 453 rs = this.check(checkElement) !== !1; 454 result = result && rs; 455 if (rs) { 456 this.invalid[checkElement.name] = !1; 457 } else { 458 this.invalid[checkElement.name] = !0; 459 } 460 if (!this.numberOfInvalids()) { 461 this.toHide = this.toHide.add(this.containers); 462 } 463 this.showErrors(); 464 $(element).attr("aria-invalid", !rs); 465 } 466 return result; 467 }, 468 showErrors: function (errors) { 469 if (errors) { 470 var validator = this; 471 $.extend(this.errorMap, errors); 472 this.errorList = $.map(this.errorMap, function (message, name) { 473 return { message: message, element: validator.findByName(name)[0] }; 474 }); 475 this.successList = $.grep(this.successList, function (element) { 476 return !(element.name in errors); 477 }); 478 } 479 if (this.settings.showErrors) { 480 this.settings.showErrors.call(this, this.errorMap, this.errorList); 481 } else { 482 this.defaultShowErrors(); 483 } 484 }, 485 resetForm: function () { 486 if ($.fn.resetForm) { 487 $(this.currentForm).resetForm(); 488 } 489 this.invalid = {}; 490 this.submitted = {}; 491 this.prepareForm(); 492 this.hideErrors(); 493 var elements = this.elements() 494 .removeData("previousValue") 495 .removeAttr("aria-invalid"); 496 this.resetElements(elements); 497 }, 498 resetElements: function (elements) { 499 var i; 500 if (this.settings.unhighlight) { 501 for (i = 0; elements[i]; i++) { 502 this.settings.unhighlight.call( 503 this, 504 elements[i], 505 this.settings.errorClass, 506 "" 507 ); 508 this.findByName(elements[i].name).removeClass( 509 this.settings.validClass 510 ); 511 } 512 } else { 513 elements 514 .removeClass(this.settings.errorClass) 515 .removeClass(this.settings.validClass); 516 } 517 }, 518 numberOfInvalids: function () { 519 return this.objectLength(this.invalid); 520 }, 521 objectLength: function (obj) { 522 var count = 0, 523 i; 524 for (i in obj) { 525 if (obj[i] !== undefined && obj[i] !== null && obj[i] !== !1) { 526 count++; 527 } 528 } 529 return count; 530 }, 531 hideErrors: function () { 532 this.hideThese(this.toHide); 533 }, 534 hideThese: function (errors) { 535 errors.not(this.containers).text(""); 536 this.addWrapper(errors).hide(); 537 }, 538 valid: function () { 539 return this.size() === 0; 540 }, 541 size: function () { 542 return this.errorList.length; 543 }, 544 focusInvalid: function () { 545 if (this.settings.focusInvalid) { 546 try { 547 $( 548 this.findLastActive() || 549 (this.errorList.length && this.errorList[0].element) || 550 [] 551 ) 552 .filter(":visible") 553 .trigger("focus") 554 .trigger("focusin"); 555 } catch (e) {} 556 } 557 }, 558 findLastActive: function () { 559 var lastActive = this.lastActive; 560 return ( 561 lastActive && 562 $.grep(this.errorList, function (n) { 563 return n.element.name === lastActive.name; 564 }).length === 1 && 565 lastActive 566 ); 567 }, 568 elements: function () { 569 var validator = this, 570 rulesCache = {}; 571 return $(this.currentForm) 572 .find("input, select, textarea, [contenteditable]") 573 .not(":submit, :reset, :image, :disabled") 574 .not(this.settings.ignore) 575 .filter(function () { 576 var name = this.name || $(this).attr("name"); 577 var isContentEditable = 578 typeof $(this).attr("contenteditable") !== "undefined" &&
vendor: 9,175 bytes, lines 579-856
579 $(this).attr("contenteditable") !== "false"; 580 if (!name && validator.settings.debug && window.console) { 581 console.error("%o has no name assigned", this); 582 } 583 if (isContentEditable) { 584 this.form = $(this).closest("form")[0]; 585 this.name = name; 586 } 587 if (this.form !== validator.currentForm) { 588 return !1; 589 } 590 if ( 591 name in rulesCache || 592 !validator.objectLength($(this).rules()) 593 ) { 594 return !1; 595 } 596 rulesCache[name] = !0; 597 return !0; 598 }); 599 }, 600 clean: function (selector) { 601 return $(selector)[0]; 602 }, 603 errors: function () { 604 var errorClass = this.settings.errorClass.split(" ").join("."); 605 return $( 606 this.settings.errorElement + "." + errorClass, 607 this.errorContext 608 ); 609 }, 610 resetInternals: function () { 611 this.successList = []; 612 this.errorList = []; 613 this.errorMap = {}; 614 this.toShow = $([]); 615 this.toHide = $([]); 616 }, 617 reset: function () { 618 this.resetInternals(); 619 this.currentElements = $([]); 620 }, 621 prepareForm: function () { 622 this.reset(); 623 this.toHide = this.errors().add(this.containers); 624 }, 625 prepareElement: function (element) { 626 this.reset(); 627 this.toHide = this.errorsFor(element); 628 }, 629 elementValue: function (element) { 630 var $element = $(element), 631 type = element.type, 632 isContentEditable = 633 typeof $element.attr("contenteditable") !== "undefined" && 634 $element.attr("contenteditable") !== "false", 635 val, 636 idx; 637 if (type === "radio" || type === "checkbox") { 638 return this.findByName(element.name).filter(":checked").val(); 639 } else if ( 640 type === "number" && 641 typeof element.validity !== "undefined" 642 ) { 643 return element.validity.badInput ? "NaN" : $element.val(); 644 } 645 if (isContentEditable) { 646 val = $element.text(); 647 } else { 648 val = $element.val(); 649 } 650 if (type === "file") { 651 if (val.substr(0, 12) === "C:\\fakepath\\") { 652 return val.substr(12); 653 } 654 idx = val.lastIndexOf("/"); 655 if (idx >= 0) { 656 return val.substr(idx + 1); 657 } 658 idx = val.lastIndexOf("\\"); 659 if (idx >= 0) { 660 return val.substr(idx + 1); 661 } 662 return val; 663 } 664 if (typeof val === "string") { 665 return val.replace(/\r/g, ""); 666 } 667 return val; 668 }, 669 check: function (element) { 670 element = this.validationTargetFor(this.clean(element)); 671 var rules = $(element).rules(), 672 rulesCount = $.map(rules, function (n, i) { 673 return i; 674 }).length, 675 dependencyMismatch = !1, 676 val = this.elementValue(element), 677 result, 678 method, 679 rule, 680 normalizer; 681 if (typeof rules.normalizer === "function") { 682 normalizer = rules.normalizer; 683 } else if (typeof this.settings.normalizer === "function") { 684 normalizer = this.settings.normalizer; 685 } 686 if (normalizer) { 687 val = normalizer.call(element, val); 688 delete rules.normalizer; 689 } 690 for (method in rules) { 691 rule = { method: method, parameters: rules[method] }; 692 try { 693 result = $.validator.methods[method].call( 694 this, 695 val, 696 element, 697 rule.parameters 698 ); 699 if (result === "dependency-mismatch" && rulesCount === 1) { 700 dependencyMismatch = !0; 701 continue; 702 } 703 dependencyMismatch = !1; 704 if (result === "pending") { 705 this.toHide = this.toHide.not(this.errorsFor(element)); 706 return; 707 } 708 if (!result) { 709 this.formatAndAdd(element, rule); 710 return !1; 711 } 712 } catch (e) { 713 if (this.settings.debug && window.console) { 714 console.log( 715 "Exception occurred when checking element " + 716 element.id + 717 ", check the '" + 718 rule.method + 719 "' method.", 720 e 721 ); 722 } 723 if (e instanceof TypeError) { 724 e.message += 725 ". Exception occurred when checking element " + 726 element.id + 727 ", check the '" + 728 rule.method + 729 "' method."; 730 } 731 throw e; 732 } 733 } 734 if (dependencyMismatch) { 735 return; 736 } 737 if (this.objectLength(rules)) { 738 this.successList.push(element); 739 } 740 return !0; 741 }, 742 customDataMessage: function (element, method) { 743 return ( 744 $(element).data( 745 "msg" + 746 method.charAt(0).toUpperCase() + 747 method.substring(1).toLowerCase() 748 ) || $(element).data("msg") 749 ); 750 }, 751 customMessage: function (name, method) { 752 var m = this.settings.messages[name]; 753 return m && (m.constructor === String ? m : m[method]); 754 }, 755 findDefined: function () { 756 for (var i = 0; i < arguments.length; i++) { 757 if (arguments[i] !== undefined) { 758 return arguments[i]; 759 } 760 } 761 return undefined; 762 }, 763 defaultMessage: function (element, rule) { 764 if (typeof rule === "string") { 765 rule = { method: rule }; 766 } 767 var message = this.findDefined( 768 this.customMessage(element.name, rule.method), 769 this.customDataMessage(element, rule.method), 770 (!this.settings.ignoreTitle && element.title) || undefined, 771 $.validator.messages[rule.method], 772 "<strong>Warning: No message defined for " + 773 element.name + 774 "</strong>" 775 ), 776 theregex = /\$?\{(\d+)\}/g; 777 if (typeof message === "function") { 778 message = message.call(this, rule.parameters, element); 779 } else if (theregex.test(message)) { 780 message = $.validator.format( 781 message.replace(theregex, "{$1}"), 782 rule.parameters 783 ); 784 } 785 return message; 786 }, 787 formatAndAdd: function (element, rule) { 788 var message = this.defaultMessage(element, rule); 789 this.errorList.push({ 790 message: message, 791 element: element, 792 method: rule.method, 793 }); 794 this.errorMap[element.name] = message; 795 this.submitted[element.name] = message; 796 }, 797 addWrapper: function (toToggle) { 798 if (this.settings.wrapper) { 799 toToggle = toToggle.add(toToggle.parent(this.settings.wrapper)); 800 } 801 return toToggle; 802 }, 803 defaultShowErrors: function () { 804 var i, elements, error; 805 for (i = 0; this.errorList[i]; i++) { 806 error = this.errorList[i]; 807 if (this.settings.highlight) { 808 this.settings.highlight.call( 809 this, 810 error.element, 811 this.settings.errorClass, 812 this.settings.validClass 813 ); 814 } 815 this.showLabel(error.element, error.message); 816 } 817 if (this.errorList.length) { 818 this.toShow = this.toShow.add(this.containers); 819 } 820 if (this.settings.success) { 821 for (i = 0; this.successList[i]; i++) { 822 this.showLabel(this.successList[i]); 823 } 824 } 825 if (this.settings.unhighlight) { 826 for (i = 0, elements = this.validElements(); elements[i]; i++) { 827 this.settings.unhighlight.call( 828 this, 829 elements[i], 830 this.settings.errorClass, 831 this.settings.validClass 832 ); 833 } 834 } 835 this.toHide = this.toHide.not(this.toShow); 836 this.hideErrors(); 837 this.addWrapper(this.toShow).show(); 838 }, 839 validElements: function () { 840 return this.currentElements.not(this.invalidElements()); 841 }, 842 invalidElements: function () { 843 return $(this.errorList).map(function () { 844 return this.element; 845 }); 846 }, 847 showLabel: function (element, message) { 848 var place, 849 group, 850 errorID, 851 v, 852 error = this.errorsFor(element), 853 elementID = this.idOrName(element), 854 describedBy = $(element).attr("aria-describedby"); 855 if (error.length) { 856 error
857 .removeClass(this.settings.validClass) 858 .addClass(this.settings.errorClass); 859 error.html(message); 860 } else { 861 error = $("<" + this.settings.errorElement + ">") 862 .attr("id", elementID + "-error") 863 .addClass(this.settings.errorClass) 864 .html(message || ""); 865 place = error; 866 if (this.settings.wrapper) { 867 place = error 868 .hide() 869 .show() 870 .wrap("<" + this.settings.wrapper + ">") 871 .parent(); 872 } 873 if (this.labelContainer.length) { 874 this.labelContainer.append(place); 875 } else if (this.settings.errorPlacement) { 876 this.settings.errorPlacement.call(this, place, $(element)); 877 } else { 878 place.insertAfter(element); 879 } 880 if (error.is("label")) { 881 error.attr("for", elementID); 882 } else if ( 883 error.parents("label[for='" + this.escapeCssMeta(elementID) + "']") 884 .length === 0 885 ) { 886 errorID = error.attr("id"); 887 if (!describedBy) { 888 describedBy = errorID; 889 } else if ( 890 !describedBy.match( 891 new RegExp("\\b" + this.escapeCssMeta(errorID) + "\\b") 892 ) 893 ) { 894 describedBy += " " + errorID; 895 } 896 $(element).attr("aria-describedby", describedBy); 897 group = this.groups[element.name]; 898 if (group) { 899 v = this; 900 $.each(v.groups, function (name, testgroup) { 901 if (testgroup === group) { 902 $( 903 "[name='" + v.escapeCssMeta(name) + "']", 904 v.currentForm 905 ).attr("aria-describedby", error.attr("id")); 906 } 907 }); 908 } 909 } 910 } 911 if (!message && this.settings.success) { 912 error.text(""); 913 if (typeof this.settings.success === "string") { 914 error.addClass(this.settings.success); 915 } else { 916 this.settings.success(error, element); 917 } 918 } 919 this.toShow = this.toShow.add(error); 920 }, 921 errorsFor: function (element) { 922 var name = this.escapeCssMeta(this.idOrName(element)), 923 describer = $(element).attr("aria-describedby"), 924 selector = "label[for='" + name + "'], label[for='" + name + "'] *"; 925 if (describer) { 926 selector = 927 selector + 928 ", #" + 929 this.escapeCssMeta(describer).replace(/\s+/g, ", #"); 930 } 931 return this.errors().filter(selector); 932 }, 933 escapeCssMeta: function (string) { 934 if (string === undefined) { 935 return ""; 936 } 937 return string.replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g, "\\$1"); 938 }, 939 idOrName: function (element) { 940 return ( 941 this.groups[element.name] || 942 (this.checkable(element) ? element.name : element.id || element.name) 943 ); 944 }, 945 validationTargetFor: function (element) { 946 if (this.checkable(element)) { 947 element = this.findByName(element.name); 948 } 949 return $(element).not(this.settings.ignore)[0]; 950 }, 951 checkable: function (element) { 952 return /radio|checkbox/i.test(element.type); 953 }, 954 findByName: function (name) { 955 return $(this.currentForm).find( 956 "[name='" + this.escapeCssMeta(name) + "']" 957 ); 958 }, 959 getLength: function (value, element) { 960 switch (element.nodeName.toLowerCase()) { 961 case "select": 962 return $("option:selected", element).length; 963 case "input": 964 if (this.checkable(element)) { 965 return this.findByName(element.name).filter(":checked").length; 966 } 967 } 968 return value.length; 969 }, 970 depend: function (param, element) { 971 return this.dependTypes[typeof param] 972 ? this.dependTypes[typeof param](param, element) 973 : !0; 974 }, 975 dependTypes: { 976 boolean: function (param) { 977 return param; 978 },
979 string: function (param, element) { 980 return !!$(param, element.form).length; 981 }, 982 function: function (param, element) { 983 return param(element); 984 }, 985 }, 986 optional: function (element) { 987 var val = this.elementValue(element); 988 return ( 989 !$.validator.methods.required.call(this, val, element) && 990 "dependency-mismatch" 991 ); 992 }, 993 startRequest: function (element) { 994 if (!this.pending[element.name]) { 995 this.pendingRequest++; 996 $(element).addClass(this.settings.pendingClass); 997 this.pending[element.name] = !0; 998 } 999 }, 1000 stopRequest: function (element, valid) { 1001 this.pendingRequest--; 1002 if (this.pendingRequest < 0) { 1003 this.pendingRequest = 0; 1004 } 1005 delete this.pending[element.name]; 1006 $(element).removeClass(this.settings.pendingClass); 1007 if ( 1008 valid && 1009 this.pendingRequest === 0 && 1010 this.formSubmitted && 1011 this.form() && 1012 this.pendingRequest === 0 1013 ) { 1014 $(this.currentForm).trigger("submit"); 1015 if (this.submitButton) { 1016 $( 1017 "input:hidden[name='" + this.submitButton.name + "']", 1018 this.currentForm 1019 ).remove(); 1020 } 1021 this.formSubmitted = !1; 1022 } else if (!valid && this.pendingRequest === 0 && this.formSubmitted) { 1023 $(this.currentForm).triggerHandler("invalid-form", [this]); 1024 this.formSubmitted = !1; 1025 } 1026 }, 1027 previousValue: function (element, method) { 1028 method = (typeof method === "string" && method) || "remote"; 1029 return ( 1030 $.data(element, "previousValue") || 1031 $.data(element, "previousValue", { 1032 old: null, 1033 valid: !0, 1034 message: this.defaultMessage(element, { method: method }), 1035 }) 1036 ); 1037 }, 1038 destroy: function () { 1039 this.resetForm(); 1040 $(this.currentForm) 1041 .off(".validate") 1042 .removeData("validator") 1043 .find(".validate-equalTo-blur") 1044 .off(".validate-equalTo") 1045 .removeClass("validate-equalTo-blur") 1046 .find(".validate-lessThan-blur") 1047 .off(".validate-lessThan") 1048 .removeClass("validate-lessThan-blur") 1049 .find(".validate-lessThanEqual-blur") 1050 .off(".validate-lessThanEqual") 1051 .removeClass("validate-lessThanEqual-blur") 1052 .find(".validate-greaterThanEqual-blur") 1053 .off(".validate-greaterThanEqual") 1054 .removeClass("validate-greaterThanEqual-blur") 1055 .find(".validate-greaterThan-blur") 1056 .off(".validate-greaterThan") 1057 .removeClass("validate-greaterThan-blur"); 1058 }, 1059 }, 1060 classRuleSettings: { 1061 required: { required: !0 }, 1062 email: { email: !0 }, 1063 url: { url: !0 }, 1064 date: { date: !0 }, 1065 dateISO: { dateISO: !0 }, 1066 number: { number: !0 }, 1067 digits: { digits: !0 }, 1068 creditcard: { creditcard: !0 }, 1069 }, 1070 addClassRules: function (className, rules) { 1071 if (className.constructor === String) { 1072 this.classRuleSettings[className] = rules; 1073 } else { 1074 $.extend(this.classRuleSettings, className); 1075 } 1076 }, 1077 classRules: function (element) { 1078 var rules = {}, 1079 classes = $(element).attr("class"); 1080 if (classes) { 1081 $.each(classes.split(" "), function () { 1082 if (this in $.validator.classRuleSettings) { 1083 $.extend(rules, $.validator.classRuleSettings[this]); 1084 } 1085 }); 1086 } 1087 return rules; 1088 }, 1089 normalizeAttributeRule: function (rules, type, method, value) { 1090 if ( 1091 /min|max|step/.test(method) && 1092 (type === null || /number|range|text/.test(type)) 1093 ) { 1094 value = Number(value); 1095 if (isNaN(value)) { 1096 value = undefined; 1097 } 1098 } 1099 if (value || value === 0) { 1100 rules[method] = value; 1101 } else if (type === method && type !== "range") { 1102 rules[type === "date" ? "dateISO" : method] = !0; 1103 } 1104 }, 1105 attributeRules: function (element) { 1106 var rules = {}, 1107 $element = $(element), 1108 type = element.getAttribute("type"), 1109 method, 1110 value; 1111 for (method in $.validator.methods) { 1112 if (method === "required") { 1113 value = element.getAttribute(method); 1114 if (value === "") { 1115 value = !0; 1116 } 1117 value = !!value; 1118 } else { 1119 value = $element.attr(method); 1120 } 1121 this.normalizeAttributeRule(rules, type, method, value); 1122 } 1123 if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) { 1124 delete rules.maxlength; 1125 } 1126 return rules; 1127 }, 1128 dataRules: function (element) { 1129 var rules = {}, 1130 $element = $(element), 1131 type = element.getAttribute("type"), 1132 method, 1133 value; 1134 for (method in $.validator.methods) { 1135 value = $element.data( 1136 "rule" + 1137 method.charAt(0).toUpperCase() + 1138 method.substring(1).toLowerCase() 1139 ); 1140 if (value === "") { 1141 value = !0; 1142 } 1143 this.normalizeAttributeRule(rules, type, method, value); 1144 } 1145 return rules; 1146 }, 1147 staticRules: function (element) { 1148 var rules = {}, 1149 validator = $.data(element.form, "validator"); 1150 if (validator.settings.rules) { 1151 rules = 1152 $.validator.normalizeRule(validator.settings.rules[element.name]) || 1153 {}; 1154 } 1155 return rules; 1156 }, 1157 normalizeRules: function (rules, element) { 1158 $.each(rules, function (prop, val) { 1159 if (val === !1) { 1160 delete rules[prop]; 1161 return; 1162 } 1163 if (val.param || val.depends) { 1164 var keepRule = !0; 1165 switch (typeof val.depends) { 1166 case "string": 1167 keepRule = !!$(val.depends, element.form).length; 1168 break; 1169 case "function": 1170 keepRule = val.depends.call(element, element); 1171 break; 1172 } 1173 if (keepRule) { 1174 rules[prop] = val.param !== undefined ? val.param : !0; 1175 } else { 1176 $.data(element.form, "validator").resetElements($(element)); 1177 delete rules[prop]; 1178 } 1179 } 1180 }); 1181 $.each(rules, function (rule, parameter) { 1182 rules[rule] =
vendor: 2,714 bytes, lines 1183-1259
1183 typeof parameter === "function" && rule !== "normalizer" 1184 ? parameter(element) 1185 : parameter; 1186 }); 1187 $.each(["minlength", "maxlength"], function () { 1188 if (rules[this]) { 1189 rules[this] = Number(rules[this]); 1190 } 1191 }); 1192 $.each(["rangelength", "range"], function () { 1193 var parts; 1194 if (rules[this]) { 1195 if (Array.isArray(rules[this])) { 1196 rules[this] = [Number(rules[this][0]), Number(rules[this][1])]; 1197 } else if (typeof rules[this] === "string") { 1198 parts = rules[this].replace(/[\[\]]/g, "").split(/[\s,]+/); 1199 rules[this] = [Number(parts[0]), Number(parts[1])]; 1200 } 1201 } 1202 }); 1203 if ($.validator.autoCreateRanges) { 1204 if (rules.min != null && rules.max != null) { 1205 rules.range = [rules.min, rules.max]; 1206 delete rules.min; 1207 delete rules.max; 1208 } 1209 if (rules.minlength != null && rules.maxlength != null) { 1210 rules.rangelength = [rules.minlength, rules.maxlength]; 1211 delete rules.minlength; 1212 delete rules.maxlength; 1213 } 1214 } 1215 return rules; 1216 }, 1217 normalizeRule: function (data) { 1218 if (typeof data === "string") { 1219 var transformed = {}; 1220 $.each(data.split(/\s/), function () { 1221 transformed[this] = !0; 1222 }); 1223 data = transformed; 1224 } 1225 return data; 1226 }, 1227 addMethod: function (name, method, message) { 1228 $.validator.methods[name] = method; 1229 $.validator.messages[name] = 1230 message !== undefined ? message : $.validator.messages[name]; 1231 if (method.length < 3) { 1232 $.validator.addClassRules(name, $.validator.normalizeRule(name)); 1233 } 1234 }, 1235 methods: { 1236 required: function (value, element, param) { 1237 if (!this.depend(param, element)) { 1238 return "dependency-mismatch"; 1239 } 1240 if (element.nodeName.toLowerCase() === "select") { 1241 var val = $(element).val(); 1242 return val && val.length > 0; 1243 } 1244 if (this.checkable(element)) { 1245 return this.getLength(value, element) > 0; 1246 } 1247 return value !== undefined && value !== null && value.length > 0; 1248 }, 1249 email: function (value, element) { 1250 return ( 1251 this.optional(element) || 1252 /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test( 1253 value 1254 ) 1255 ); 1256 }, 1257 url: function (value, element) { 1258 return ( 1259 this.optional(element) ||
1260 /^(?:(?:(?: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,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( 1261 value 1262 ) 1263 ); 1264 }, 1265 date: (function () { 1266 var called = !1; 1267 return function (value, element) { 1268 if (!called) { 1269 called = !0; 1270 if (this.settings.debug && window.console) { 1271 console.warn( 1272 "The `date` method is deprecated and will be removed in version '2.0.0'.\n" + 1273 "Please don't use it, since it relies on the Date constructor, which\n" + 1274 "behaves very differently across browsers and locales. Use `dateISO`\n" + 1275 "instead or one of the locale specific methods in `localizations/`\n" + 1276 "and `additional-methods.js`." 1277 ); 1278 } 1279 } 1280 return ( 1281 this.optional(element) || 1282 !/Invalid|NaN/.test(new Date(value).toString()) 1283 ); 1284 }; 1285 })(), 1286 dateISO: function (value, element) { 1287 return ( 1288 this.optional(element) || 1289 /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test( 1290 value 1291 ) 1292 ); 1293 }, 1294 number: function (value, element) { 1295 return ( 1296 this.optional(element) || 1297 /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value) 1298 ); 1299 }, 1300 digits: function (value, element) { 1301 return this.optional(element) || /^\d+$/.test(value); 1302 }, 1303 minlength: function (value, element, param) { 1304 var length = Array.isArray(value) 1305 ? value.length 1306 : this.getLength(value, element); 1307 return this.optional(element) || length >= param; 1308 }, 1309 maxlength: function (value, element, param) { 1310 var length = Array.isArray(value) 1311 ? value.length 1312 : this.getLength(value, element); 1313 return this.optional(element) || length <= param; 1314 }, 1315 rangelength: function (value, element, param) { 1316 var length = Array.isArray(value) 1317 ? value.length 1318 : this.getLength(value, element); 1319 return ( 1320 this.optional(element) || (length >= param[0] && length <= param[1]) 1321 ); 1322 }, 1323 min: function (value, element, param) { 1324 return this.optional(element) || value >= param; 1325 }, 1326 max: function (value, element, param) { 1327 return this.optional(element) || value <= param; 1328 }, 1329 range: function (value, element, param) { 1330 return ( 1331 this.optional(element) || (value >= param[0] && value <= param[1]) 1332 ); 1333 }, 1334 step: function (value, element, param) { 1335 var type = $(element).attr("type"), 1336 errorMessage = 1337 "Step attribute on input type " + type + " is not supported.", 1338 supportedTypes = ["text", "number", "range"], 1339 re = new RegExp("\\b" + type + "\\b"), 1340 notSupported = type && !re.test(supportedTypes.join()), 1341 decimalPlaces = function (num) { 1342 var match = ("" + num).match(/(?:\.(\d+))?$/); 1343 if (!match) { 1344 return 0; 1345 } 1346 return match[1] ? match[1].length : 0; 1347 }, 1348 toInt = function (num) { 1349 return Math.round(num * Math.pow(10, decimals)); 1350 }, 1351 valid = !0, 1352 decimals; 1353 if (notSupported) { 1354 throw new Error(errorMessage); 1355 } 1356 decimals = decimalPlaces(param); 1357 if ( 1358 decimalPlaces(value) > decimals || 1359 toInt(value) % toInt(param) !== 0 1360 ) { 1361 valid = !1; 1362 } 1363 return this.optional(element) || valid; 1364 }, 1365 equalTo: function (value, element, param) { 1366 var target = $(param); 1367 if ( 1368 this.settings.onfocusout && 1369 target.not(".validate-equalTo-blur").length 1370 ) { 1371 target
1372 .addClass("validate-equalTo-blur") 1373 .on("blur.validate-equalTo", function () { 1374 $(element).valid(); 1375 }); 1376 } 1377 return value === target.val(); 1378 }, 1379 remote: function (value, element, param, method) { 1380 if (this.optional(element)) { 1381 return "dependency-mismatch"; 1382 } 1383 method = (typeof method === "string" && method) || "remote"; 1384 var previous = this.previousValue(element, method), 1385 validator, 1386 data, 1387 optionDataString; 1388 if (!this.settings.messages[element.name]) { 1389 this.settings.messages[element.name] = {}; 1390 } 1391 previous.originalMessage = 1392 previous.originalMessage || 1393 this.settings.messages[element.name][method]; 1394 this.settings.messages[element.name][method] = previous.message; 1395 param = (typeof param === "string" && { url: param }) || param; 1396 optionDataString = $.param($.extend({ data: value }, param.data)); 1397 if (previous.old === optionDataString) { 1398 return previous.valid; 1399 } 1400 previous.old = optionDataString; 1401 validator = this; 1402 this.startRequest(element); 1403 data = {}; 1404 data[element.name] = value; 1405 $.ajax( 1406 $.extend( 1407 !0, 1408 { 1409 mode: "abort", 1410 port: "validate" + element.name, 1411 dataType: "json", 1412 data: data, 1413 context: validator.currentForm, 1414 success: function (response) { 1415 var valid = response === !0 || response === "true", 1416 errors, 1417 message, 1418 submitted; 1419 validator.settings.messages[element.name][method] = 1420 previous.originalMessage; 1421 if (valid) { 1422 submitted = validator.formSubmitted; 1423 validator.resetInternals(); 1424 validator.toHide = validator.errorsFor(element); 1425 validator.formSubmitted = submitted; 1426 validator.successList.push(element); 1427 validator.invalid[element.name] = !1; 1428 validator.showErrors(); 1429 } else { 1430 errors = {}; 1431 message = 1432 response || 1433 validator.defaultMessage(element, { 1434 method: method, 1435 parameters: value, 1436 }); 1437 errors[element.name] = previous.message = message; 1438 validator.invalid[element.name] = !0; 1439 validator.showErrors(errors); 1440 } 1441 previous.valid = valid; 1442 validator.stopRequest(element, valid); 1443 }, 1444 }, 1445 param 1446 ) 1447 ); 1448 return "pending"; 1449 }, 1450 }, 1451 }); 1452 var pendingRequests = {}, 1453 ajax; 1454 if ($.ajaxPrefilter) { 1455 $.ajaxPrefilter(function (settings, _, xhr) { 1456 var port = settings.port; 1457 if (settings.mode === "abort") { 1458 if (pendingRequests[port]) { 1459 pendingRequests[port].abort(); 1460 } 1461 pendingRequests[port] = xhr; 1462 } 1463 }); 1464 } else { 1465 ajax = $.ajax; 1466 $.ajax = function (settings) { 1467 var mode = ("mode" in settings ? settings : $.ajaxSettings).mode, 1468 port = ("port" in settings ? settings : $.ajaxSettings).port; 1469 if (mode === "abort") { 1470 if (pendingRequests[port]) { 1471 pendingRequests[port].abort(); 1472 } 1473 pendingRequests[port] = ajax.apply(this, arguments); 1474 return pendingRequests[port]; 1475 } 1476 return ajax.apply(this, arguments); 1477 }; 1478 } 1479 return $; 1480});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.