PageSourceSearch

https://js.carpetexpress.com/js/jquery.validate.js?ver=17092026

js carpetexpress.com collected 2026-10-05 02:07:34 UTC 56,239 bytes, 1,199 lines download raw bytes

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

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.