PageSourceSearch

https://congresocice.es/assets/libs/jquery.validate.js

js congresocice.es collected 2026-10-07 19:03:56 UTC 59,298 bytes, 1,378 lines download raw bytes

1/*!
2 * jQuery Validation Plugin v1.13.1
3 *
4 * http://jqueryvalidation.org/
5 *
6 * Copyright (c) 2014 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 {
13        factory( jQuery );
14    }
15}(function( $ ) {
16
17    $.extend($.fn, {
18        // http://jqueryvalidation.org/validate/
19        validate: function( options ) {
20
21            // if nothing is selected, return nothing; can't chain anyway
22            if ( !this.length ) {
23                if ( options && options.debug && window.console ) {
24                    console.warn( "Nothing selected, can't validate, returning nothing." );
25                }
26                return;
27            }
28
29            // check if a validator for this form was already created
30            var validator = $.data( this[ 0 ], "validator" );
31            if ( validator ) {
32                return validator;
33            }
34
35            // Add novalidate tag if HTML5.
36            this.attr( "novalidate", "novalidate" );
37
38            validator = new $.validator( options, this[ 0 ] );
39            $.data( this[ 0 ], "validator", validator );
40
41            if ( validator.settings.onsubmit ) {
42
43                this.validateDelegate( ":submit", "click", function( event ) {
44                    if ( validator.settings.submitHandler ) {
45                        validator.submitButton = event.target;
46                    }
47                    // allow suppressing validation by adding a cancel class to the submit button
48                    if ( $( event.target ).hasClass( "cancel" ) ) {
49                        validator.cancelSubmit = true;
50                    }
51
52                    // allow suppressing validation by adding the html5 formnovalidate attribute to the submit button
53                    if ( $( event.target ).attr( "formnovalidate" ) !== undefined ) {
54                        validator.cancelSubmit = true;
55                    }
56                });
57
58                // validate the form on submit
59                this.submit( function( event ) {
60                    if ( validator.settings.debug ) {
61                        // prevent form submit to be able to see console output
62                        event.preventDefault();
63                    }
64                    function handle() {
65                        var hidden, result;
66                        if ( validator.settings.submitHandler ) {
67                            if ( validator.submitButton ) {
68                                // insert a hidden input as a replacement for the missing submit button
69                                hidden = $( "<input type='hidden'/>" )
70                                    .attr( "name", validator.submitButton.name )
71                                    .val( $( validator.submitButton ).val() )
72                                    .appendTo( validator.currentForm );
73                            }
74                            result = validator.settings.submitHandler.call( validator, validator.currentForm, event );
75                            if ( validator.submitButton ) {
76                                // and clean up afterwards; thanks to no-block-scope, hidden can be referenced
77                                hidden.remove();
78                            }
79                            if ( result !== undefined ) {
80                                return result;
81                            }
82                            return false;
83                        }
84                        return true;
85                    }
86
87                    // prevent submit for invalid forms or custom submit handlers
88                    if ( validator.cancelSubmit ) {
89                        validator.cancelSubmit = false;
90                        return handle();
91                    }
92                    if ( validator.form() ) {
93                        if ( validator.pendingRequest ) {
94                            validator.formSubmitted = true;
95                            return false;
96                        }
97                        return handle();
98                    } else {
99                        validator.focusInvalid();
100                        return false;
101                    }
102                });
103            }
104
105            return validator;
106        },
107        // http://jqueryvalidation.org/valid/
108        valid: function() {
109            var valid, validator;
110
111            if ( $( this[ 0 ] ).is( "form" ) ) {
112                valid = this.validate().form();
113            } else {
114                valid = true;
115                validator = $( this[ 0 ].form ).validate();
116                this.each( function() {
117                    valid = validator.element( this ) && valid;
118                });
119            }
120            return valid;
121        },
122        // attributes: space separated list of attributes to retrieve and remove
123        removeAttrs: function( attributes ) {
124            var result = {},
125                $element = this;
126            $.each( attributes.split( /\s/ ), function( index, value ) {
127                result[ value ] = $element.attr( value );
128                $element.removeAttr( value );
129            });
130            return result;
131        },
132        // http://jqueryvalidation.org/rules/
133        rules: function( command, argument ) {
134            var element = this[ 0 ],
135                settings, staticRules, existingRules, data, param, filtered;
136
137            if ( command ) {
138                settings = $.data( element.form, "validator" ).settings;
139                staticRules = settings.rules;
140                existingRules = $.validator.staticRules( element );
141                switch ( command ) {
142                    case "add":
143                        $.extend( existingRules, $.validator.normalizeRule( argument ) );
144                        // remove messages from rules, but allow them to be set separately
145                        delete existingRules.messages;
146                        staticRules[ element.name ] = existingRules;
147                        if ( argument.messages ) {
148                            settings.messages[ element.name ] = $.extend( settings.messages[ element.name ], argument.messages );
149                        }
150                        break;
151                    case "remove":
152                        if ( !argument ) {
153                            delete staticRules[ element.name ];
154                            return existingRules;
155                        }
156                        filtered = {};
157                        $.each( argument.split( /\s/ ), function( index, method ) {
158                            filtered[ method ] = existingRules[ method ];
159                            delete existingRules[ method ];
160                            if ( method === "required" ) {
161                                $( element ).removeAttr( "aria-required" );
162                            }
163                        });
164                        return filtered;
165                }
166            }
167
168            data = $.validator.normalizeRules(
169                $.extend(
170                    {},
171                    $.validator.classRules( element ),
172                    $.validator.attributeRules( element ),
173                    $.validator.dataRules( element ),
174                    $.validator.staticRules( element )
175                ), element );
176
177            // make sure required is at front
178            if ( data.required ) {
179                param = data.required;
180                delete data.required;
181                data = $.extend( { required: param }, data );
182                $( element ).attr( "aria-required", "true" );
183            }
184
185            // make sure remote is at back
186            if ( data.remote ) {
187                param = data.remote;
188                delete data.remote;
189                data = $.extend( data, { remote: param });
190            }
191
192            return data;
193        }
194    });
195
196// Custom selectors
197    $.extend( $.expr[ ":" ], {
198        // http://jqueryvalidation.org/blank-selector/
199        blank: function( a ) {
200            return !$.trim( "" + $( a ).val() );
201        },
202        // http://jqueryvalidation.org/filled-selector/
203        filled: function( a ) {
204            return !!$.trim( "" + $( a ).val() );
205        },
206        // http://jqueryvalidation.org/unchecked-selector/
207        unchecked: function( a ) {
208            return !$( a ).prop( "checked" );
209        }
210    });
211
212// constructor for validator
213    $.validator = function( options, form ) {
214        this.settings = $.extend( true, {}, $.validator.defaults, options );
215        this.currentForm = form;
216        this.init();
217    };
218
219// http://jqueryvalidation.org/jQuery.validator.format/
220    $.validator.format = function( source, params ) {
221        if ( arguments.length === 1 ) {
222            return function() {
223                var args = $.makeArray( arguments );
224                args.unshift( source );
225                return $.validator.format.apply( this, args );
226            };
227        }
228        if ( arguments.length > 2 && params.constructor !== Array  ) {
229            params = $.makeArray( arguments ).slice( 1 );
230        }
231        if ( params.constructor !== Array ) {
232            params = [ params ];
233        }
234        $.each( params, function( i, n ) {
235            source = source.replace( new RegExp( "\\{" + i + "\\}", "g" ), function() {
236                return n;
237            });
238        });
239        return source;
240    };
241
242    $.extend( $.validator, {
243
244        defaults: {
245            messages: {},
246            groups: {},
247            rules: {},
248            errorClass: "error",
249            validClass: "valid",
250            errorElement: "label",
251            focusCleanup: false,
252            focusInvalid: true,
253            errorContainer: $( [] ),
254            errorLabelContainer: $( [] ),
255            onsubmit: true,
256            ignore: ":hidden",
257            ignoreTitle: false,
258            onfocusin: function( element ) {
259                this.lastActive = element;
260
261                // Hide error label and remove error class on focus if enabled
262                if ( this.settings.focusCleanup ) {
263                    if ( this.settings.unhighlight ) {
264                        this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.val
vendor: 4,464 bytes, lines 264-361
264idClass );
265                    }
266                    this.hideThese( this.errorsFor( element ) );
267                }
268            },
269            onfocusout: function( element ) {
270                if ( !this.checkable( element ) && ( element.name in this.submitted || !this.optional( element ) ) ) {
271                    this.element( element );
272                }
273            },
274            onkeyup: function( element, event ) {
275                if ( event.which === 9 && this.elementValue( element ) === "" ) {
276                    return;
277                } else if ( element.name in this.submitted || element === this.lastElement ) {
278                    this.element( element );
279                }
280            },
281            onclick: function( element ) {
282                // click on selects, radiobuttons and checkboxes
283                if ( element.name in this.submitted ) {
284                    this.element( element );
285
286                    // or option elements, check parent select in that case
287                } else if ( element.parentNode.name in this.submitted ) {
288                    this.element( element.parentNode );
289                }
290            },
291            highlight: function( element, errorClass, validClass ) {
292                if ( element.type === "radio" ) {
293                    this.findByName( element.name ).addClass( errorClass ).removeClass( validClass );
294                } else {
295                    $( element ).addClass( errorClass ).removeClass( validClass );
296                }
297            },
298            unhighlight: function( element, errorClass, validClass ) {
299                if ( element.type === "radio" ) {
300                    this.findByName( element.name ).removeClass( errorClass ).addClass( validClass );
301                } else {
302                    $( element ).removeClass( errorClass ).addClass( validClass );
303                }
304            }
305        },
306
307        // http://jqueryvalidation.org/jQuery.validator.setDefaults/
308        setDefaults: function( settings ) {
309            $.extend( $.validator.defaults, settings );
310        },
311
312        messages: {
313            required: "This field is required.",
314            remote: "Please fix this field.",
315            email: "Please enter a valid email address.",
316            url: "Please enter a valid URL.",
317            date: "Please enter a valid date.",
318            dateISO: "Please enter a valid date ( ISO ).",
319            number: "Please enter a valid number.",
320            digits: "Please enter only digits.",
321            creditcard: "Please enter a valid credit card number.",
322            equalTo: "Please enter the same value again.",
323            maxlength: $.validator.format( "Please enter no more than {0} characters." ),
324            minlength: $.validator.format( "Please enter at least {0} characters." ),
325            rangelength: $.validator.format( "Please enter a value between {0} and {1} characters long." ),
326            range: $.validator.format( "Please enter a value between {0} and {1}." ),
327            max: $.validator.format( "Please enter a value less than or equal to {0}." ),
328            min: $.validator.format( "Please enter a value greater than or equal to {0}." )
329        },
330
331        autoCreateRanges: false,
332
333        prototype: {
334
335            init: function() {
336                this.labelContainer = $( this.settings.errorLabelContainer );
337                this.errorContext = this.labelContainer.length && this.labelContainer || $( this.currentForm );
338                this.containers = $( this.settings.errorContainer ).add( this.settings.errorLabelContainer );
339                this.submitted = {};
340                this.valueCache = {};
341                this.pendingRequest = 0;
342                this.pending = {};
343                this.invalid = {};
344                this.reset();
345
346                var groups = ( this.groups = {} ),
347                    rules;
348                $.each( this.settings.groups, function( key, value ) {
349                    if ( typeof value === "string" ) {
350                        value = value.split( /\s/ );
351                    }
352                    $.each( value, function( index, name ) {
353                        groups[ name ] = key;
354                    });
355                });
356                rules = this.settings.rules;
357                $.each( rules, function( key, value ) {
358                    rules[ key ] = $.validator.normalizeRule( value );
359                });
360
361                function delegate( event ) {
362                    var validator = $.data( this[ 0 ].form, "validator" ),
363                        eventType = "on" + event.type.replace( /^validate/, "" ),
364                        settings = validator.settings;
365                    if ( settings[ eventType ] && !this.is( settings.ignore ) ) {
366                        settings[ eventType ].call( validator, this[ 0 ], event );
367                    }
368                }
369                $( this.currentForm )
370                    .validateDelegate( ":text, [type='password'], [type='file'], select, textarea, " +
371                        "[type='number'], [type='search'] ,[type='tel'], [type='url'], " +
372                        "[type='email'], [type='datetime'], [type='date'], [type='month'], " +
373                        "[type='week'], [type='time'], [type='datetime-local'], " +
374                        "[type='range'], [type='color'], [type='radio'], [type='checkbox']",
375                        "focusin focusout keyup", delegate)
376                    // Support: Chrome, oldIE
377                    // "select" is provided as event.target when clicking a option
378                    .validateDelegate("select, option, [type='radio'], [type='checkbox']", "click", delegate);
379
380                if ( this.settings.invalidHandler ) {
381                    $( this.currentForm ).bind( "invalid-form.validate", this.settings.invalidHandler );
382                }
383
384                // Add aria-required to any Static/Data/Class required fields before first validation
385                // Screen readers require this attribute to be present before the initial submission http://www.w3.org/TR/WCAG-TECHS/ARIA2.html
386                $( this.currentForm ).find( "[required], [data-rule-required], .required" ).attr( "aria-required", "true" );
387            },
388
389            // http://jqueryvalidation.org/Validator.form/
390            form: function() {
391                this.checkForm();
392                $.extend( this.submitted, this.errorMap );
393                this.invalid = $.extend({}, this.errorMap );
394                if ( !this.valid() ) {
395                    $( this.currentForm ).triggerHandler( "invalid-form", [ this ]);
396                }
397                this.showErrors();
398                return this.valid();
399            },
400
401            checkForm: function() {
402                this.prepareForm();
403                for ( var i = 0, elements = ( this.currentElements = this.elements() ); elements[ i ]; i++ ) {
404                    this.check( elements[ i ] );
405                }
406                return this.valid();
407            },
408
409            // http://jqueryvalidation.org/Validator.element/
410            element: function( element ) {
411                var cleanElement = this.clean( element ),
412                    checkElement = this.validationTargetFor( cleanElement ),
413                    result = true;
414
415                this.lastElement = checkElement;
416
417                if ( checkElement === undefined ) {
418                    delete this.invalid[ cleanElement.name ];
419                } else {
420                    this.prepareElement( checkElement );
421                    this.currentElements = $( checkElement );
422
423                    result = this.check( checkElement ) !== false;
424                    if ( result ) {
425                        delete this.invalid[ checkElement.name ];
426                    } else {
427                        this.invalid[ checkElement.name ] = true;
428                    }
429                }
430                // Add aria-invalid status for screen readers
431                $( element ).attr( "aria-invalid", !result );
432
433                if ( !this.numberOfInvalids() ) {
434                    // Hide error containers on last error
435                    this.toHide = this.toHide.add( this.containers );
436                }
437                this.showErrors();
438                return result;
439            },
440
441            // http://jqueryvalidation.org/Validator.showErrors/
442            showErrors: function( errors ) {
443                if ( errors ) {
444                    // add items to error list and map
445                    $.extend( this.errorMap, errors );
446                    this.errorList = [];
447                    for ( var name in errors ) {
448                        this.errorList.push({
449                            message: errors[ name ],
450                            element: this.findByName( name )[ 0 ]
451                        });
452                    }
453                    // remove items from success list
454                    this.successList = $.grep( this.successList, function( element ) {
455                        return !( element.name in errors );
456                    });
457                }
458                if ( this.settings.showErrors ) {
459                    this.settings.showErrors.call( this, this.errorMap, this.errorList );
460                } else {
461                    this.defaultShowErrors();
462                }
463            },
464
465            // http://jqueryvalidation.org/Validator.resetForm/
466            resetForm: function() {
467                if ( $.fn.resetForm ) {
468                    $( this.currentForm ).resetForm();
469                }
470                this.submitted = {};
471                this.lastElement = null;
472                this.prepareForm();
473                this.hideErrors();
474                this.elements()
475                    .removeClass( this.settings.errorClass )
476                    .removeData( "previousValue" )
477                    .removeAttr( "aria-invalid" );
478            },
479
480            numberOfInvalids: function() {
481                return this.objectLength( this.invalid );
482            },
483
484            objectLength: function( obj ) {
485                /* jshint unused: false */
486                var count = 0,
487                    i;
488                for ( i in obj ) {
489                    count++;
490                }
491                return count;
492            },
493
494            hideErrors: function() {
495                this.hideThese( this.toHide );
496            },
497
498            hideThese: function( errors ) {
499                errors.not( this.containers ).text( "" );
500                this.addWrapper( errors ).hide();
501            },
502
503            valid: function() {
504                return this.size() === 0;
505            },
506
507            size: function() {
508                return this.errorList.length;
509            },
510
511            focusInvalid: function() {
512                if ( this.settings.focusInvalid ) {
513                    try {
514                        $( this.findLastActive() || this.errorList.length && this.errorList[ 0 ].element || [])
515                            .filter( ":visible" )
516                            .focus()
517                            // manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find
518                            .trigger( "focusin" );
519                    } catch ( e ) {
520                        // ignore IE throwing errors when focusing hidden elements
521                    }
522                }
523            },
524
525            findLastActive: function() {
526                var lastActive = this.lastActive;
527                return lastActive && $.grep( this.errorList, function( n ) {
528                    return n.element.name === lastActive.name;
529                }).length === 1 && lastActive;
530            },
531
532            elements: function() {
533                var validator = this,
534                    rulesCache = {};
535
536                // select all valid inputs inside the form (no submit or reset buttons)
537                return $( this.currentForm )
538                    .find( "input, select, textarea" )
539                    .not( ":submit, :reset, :image, [disabled], [readonly]" )
540                    .not( this.settings.ignore )
541                    .filter( function() {
542                        if ( !this.name && validator.settings.debug && window.console ) {
543                            console.error( "%o has no name assigned", this );
544                        }
545
546                        // select only the first element for each name, and only those with rules specified
547                        if ( this.name in rulesCache || !validator.objectLength( $( this ).rules() ) ) {
548                            return false;
549                        }
550
551                        rulesCache[ this.name ] = true;
552                        return true;
553                    });
554            },
555
556            clean: function( selector ) {
557                return $( selector )[ 0 ];
558            },
559
560            errors: function() {
561                var errorClass = this.settings.errorClass.split( " " ).join( "." );
562                return $( this.settings.errorElement + "." + errorClass, this.errorContext );
563            },
564
565            reset: function() {
566                this.successList = [];
567                this.errorList = [];
568                this.errorMap = {};
569                this.toShow = $( [] );
570                this.toHide = $( [] );
571                this.currentElements = $( [] );
572            },
573
574            prepareForm: function() {
575                this.reset();
576                this.toHide = this.errors().add( this.containers );
577            },
578
579            prepareElement: function( element ) {
580                this.reset();
581                this.toHide = this.errorsFor( element );
582            },
583
584            elementValue: function( element ) {
585                var val,
586                    $element = $( element ),
587                    type = element.type;
588
589                if ( type === "radio" || type === "checkbox" ) {
590                    return $( "input[name='" + element.name + "']:checked" ).val();
591                } else if ( type === "number" && typeof element.validity !== "undefined" ) {
592                    return element.validity.badInput ? false : $element.val();
593                }
594
595                val = $element.val();
596                if ( typeof val === "string" ) {
597                    return val.replace(/\r/g, "" );
598                }
599                return val;
600            },
601
602            check: function( element ) {
603                element = this.validationTargetFor( this.clean( element ) );
604
605                var rules = $( element ).rules(),
606                    rulesCount = $.map( rules, function( n, i ) {
607                        return i;
608                    }).length,
609                    dependencyMismatch = false,
610                    val = this.elementValue( element ),
611                    result, method, rule;
612
613                for ( method in rules ) {
614                    rule = { method: method, parameters: rules[ method ] };
615                    try {
616
617                        result = $.validator.methods[ method ].call( this, val, element, rule.parameters );
618
619                        // if a method indicates that the field is optional and therefore valid,
620                        // don't mark it as valid when there are no other rules
621                        if ( result === "dependency-mismatch" && rulesCount === 1 ) {
622                            dependencyMismatch = true;
623                            continue;
624                        }
625                        dependencyMismatch = false;
vendor: 4,124 bytes, lines 626-717
626
627                        if ( result === "pending" ) {
628                            this.toHide = this.toHide.not( this.errorsFor( element ) );
629                            return;
630                        }
631
632                        if ( !result ) {
633                            this.formatAndAdd( element, rule );
634                            return false;
635                        }
636                    } catch ( e ) {
637                        if ( this.settings.debug && window.console ) {
638                            console.log( "Exception occurred when checking element " + element.id + ", check the '" + rule.method + "' method.", e );
639                        }
640                        throw e;
641                    }
642                }
643                if ( dependencyMismatch ) {
644                    return;
645                }
646                if ( this.objectLength( rules ) ) {
647                    this.successList.push( element );
648                }
649                return true;
650            },
651
652            // return the custom message for the given element and validation method
653            // specified in the element's HTML5 data attribute
654            // return the generic message if present and no method specific message is present
655            customDataMessage: function( element, method ) {
656                return $( element ).data( "msg" + method.charAt( 0 ).toUpperCase() +
657                    method.substring( 1 ).toLowerCase() ) || $( element ).data( "msg" );
658            },
659
660            // return the custom message for the given element name and validation method
661            customMessage: function( name, method ) {
662                var m = this.settings.messages[ name ];
663                return m && ( m.constructor === String ? m : m[ method ]);
664            },
665
666            // return the first defined argument, allowing empty strings
667            findDefined: function() {
668                for ( var i = 0; i < arguments.length; i++) {
669                    if ( arguments[ i ] !== undefined ) {
670                        return arguments[ i ];
671                    }
672                }
673                return undefined;
674            },
675
676            defaultMessage: function( element, method ) {
677                return this.findDefined(
678                    this.customMessage( element.name, method ),
679                    this.customDataMessage( element, method ),
680                    // title is never undefined, so handle empty string as undefined
681                    !this.settings.ignoreTitle && element.title || undefined,
682                    $.validator.messages[ method ],
683                    "<strong>Warning: No message defined for " + element.name + "</strong>"
684                );
685            },
686
687            formatAndAdd: function( element, rule ) {
688                var message = this.defaultMessage( element, rule.method ),
689                    theregex = /\$?\{(\d+)\}/g;
690                if ( typeof message === "function" ) {
691                    message = message.call( this, rule.parameters, element );
692                } else if ( theregex.test( message ) ) {
693                    message = $.validator.format( message.replace( theregex, "{$1}" ), rule.parameters );
694                }
695                this.errorList.push({
696                    message: message,
697                    element: element,
698                    method: rule.method
699                });
700
701                this.errorMap[ element.name ] = message;
702                this.submitted[ element.name ] = message;
703            },
704
705            addWrapper: function( toToggle ) {
706                if ( this.settings.wrapper ) {
707                    toToggle = toToggle.add( toToggle.parent( this.settings.wrapper ) );
708                }
709                return toToggle;
710            },
711
712            defaultShowErrors: function() {
713                var i, elements, error;
714                for ( i = 0; this.errorList[ i ]; i++ ) {
715                    error = this.errorList[ i ];
716                    if ( this.settings.highlight ) {
717                        this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.val
717idClass );
718                    }
719                    this.showLabel( error.element, error.message );
720                }
721                if ( this.errorList.length ) {
722                    this.toShow = this.toShow.add( this.containers );
723                }
724                if ( this.settings.success ) {
725                    for ( i = 0; this.successList[ i ]; i++ ) {
726                        this.showLabel( this.successList[ i ] );
727                    }
728                }
729                if ( this.settings.unhighlight ) {
730                    for ( i = 0, elements = this.validElements(); elements[ i ]; i++ ) {
731                        this.settings.unhighlight.call( this, elements[ i ], this.settings.errorClass, this.settings.validClass );
732                    }
733                }
734                this.toHide = this.toHide.not( this.toShow );
735                this.hideErrors();
736                this.addWrapper( this.toShow ).show();
737            },
738
739            validElements: function() {
740                return this.currentElements.not( this.invalidElements() );
741            },
742
743            invalidElements: function() {
744                return $( this.errorList ).map(function() {
745                    return this.element;
746                });
747            },
748
749            showLabel: function( element, message ) {
750                var place, group, errorID,
751                    error = this.errorsFor( element ),
752                    elementID = this.idOrName( element ),
753                    describedBy = $( element ).attr( "aria-describedby" );
754                if ( error.length ) {
755                    // refresh error/success class
756                    error.removeClass( this.settings.validClass ).addClass( this.settings.errorClass );
757                    // replace message on existing label
758                    error.html( message );
759                } else {
760                    // create error element
761                    error = $( "<" + this.settings.errorElement + ">" )
762                        .attr( "id", elementID + "-error" )
763                        .addClass( this.settings.errorClass )
764                        .html( message || "" );
765
766                    // Maintain reference to the element to be placed into the DOM
767                    place = error;
768                    if ( this.settings.wrapper ) {
769                        // make sure the element is visible, even in IE
770                        // actually showing the wrapped element is handled elsewhere
771                        place = error.hide().show().wrap( "<" + this.settings.wrapper + "/>" ).parent();
772                    }
773
774                    /*console.log(this.settings);
775                     console.log(this.settings.errorPlacement);
776                     console.log(this.labelContainer);*/
777
778                    if ( this.labelContainer.length ) {
779                        this.labelContainer.append( place );
780                    } else if ( this.settings.errorPlacement ) {
781                        this.settings.errorPlacement( place, $( element ) );
782                    } else {
783                        place.insertAfter( element );
784                    }
785
786                    // Link error back to the element
787                    if ( error.is( "label" ) ) {
788                        // If the error is a label, then associate using 'for'
789                        error.attr( "for", elementID );
790                    } else if ( error.parents( "label[for='" + elementID + "']" ).length === 0 ) {
791                        // If the element is not a child of an associated label, then it's necessary
792                        // to explicitly apply aria-describedby
793
794                        errorID = error.attr( "id" ).replace( /(:|\.|\[|\])/g, "\\$1");
795                        // Respect existing non-error aria-describedby
796                        if ( !describedBy ) {
797                            describedBy = errorID;
798                        } else if ( !describedBy.match( new RegExp( "\\b" + errorID + "\\b" ) ) ) {
799                            // Add to end of list if not already present
800                            describedBy += " " + errorID;
801                        }
802                        $( element ).attr( "aria-describedby", describedBy );
803
804                        // If this element is grouped, then assign to all elements in the same group
805                        group = this.groups[ element.name ];
806                        if ( group ) {
807                            $.each( this.groups, function( name, testgroup ) {
808                                if ( testgroup === group ) {
809                                    $( "[name='" + name + "']", this.currentForm )
810                                        .attr( "aria-describedby", error.attr( "id" ) );
811                                }
812                            });
813                        }
814                    }
815                }
816                if ( !message && this.settings.success ) {
817                    error.text( "" );
818                    if ( typeof this.settings.success === "string" ) {
819                        error.addClass( this.settings.success );
820                    } else {
821                        this.settings.success( error, element );
822                    }
823                }
824                this.toShow = this.toShow.add( error );
825            },
826
827            errorsFor: function( element ) {
828                var name = this.idOrName( element ),
829                    describer = $( element ).attr( "aria-describedby" ),
830                    selector = "label[for='" + name + "'], label[for='" + name + "'] *";
831
832                // aria-describedby should directly reference the error element
833                if ( describer ) {
834                    selector = selector + ", #" + describer.replace( /\s+/g, ", #" );
835                }
836                return this
837                    .errors()
838                    .filter( selector );
839            },
840
841            idOrName: function( element ) {
842                return this.groups[ element.name ] || ( this.checkable( element ) ? element.name : element.i
vendor: 15,351 bytes, lines 842-1187
842d || element.name );
843            },
844
845            validationTargetFor: function( element ) {
846
847                // If radio/checkbox, validate first element in group instead
848                if ( this.checkable( element ) ) {
849                    element = this.findByName( element.name );
850                }
851
852                // Always apply ignore filter
853                return $( element ).not( this.settings.ignore )[ 0 ];
854            },
855
856            checkable: function( element ) {
857                return ( /radio|checkbox/i ).test( element.type );
858            },
859
860            findByName: function( name ) {
861                return $( this.currentForm ).find( "[name='" + name + "']" );
862            },
863
864            getLength: function( value, element ) {
865                switch ( element.nodeName.toLowerCase() ) {
866                    case "select":
867                        return $( "option:selected", element ).length;
868                    case "input":
869                        if ( this.checkable( element ) ) {
870                            return this.findByName( element.name ).filter( ":checked" ).length;
871                        }
872                }
873                return value.length;
874            },
875
876            depend: function( param, element ) {
877                return this.dependTypes[typeof param] ? this.dependTypes[typeof param]( param, element ) : true;
878            },
879
880            dependTypes: {
881                "boolean": function( param ) {
882                    return param;
883                },
884                "string": function( param, element ) {
885                    return !!$( param, element.form ).length;
886                },
887                "function": function( param, element ) {
888                    return param( element );
889                }
890            },
891
892            optional: function( element ) {
893                var val = this.elementValue( element );
894                return !$.validator.methods.required.call( this, val, element ) && "dependency-mismatch";
895            },
896
897            startRequest: function( element ) {
898                if ( !this.pending[ element.name ] ) {
899                    this.pendingRequest++;
900                    this.pending[ element.name ] = true;
901                }
902            },
903
904            stopRequest: function( element, valid ) {
905                this.pendingRequest--;
906                // sometimes synchronization fails, make sure pendingRequest is never < 0
907                if ( this.pendingRequest < 0 ) {
908                    this.pendingRequest = 0;
909                }
910                delete this.pending[ element.name ];
911                if ( valid && this.pendingRequest === 0 && this.formSubmitted && this.form() ) {
912                    $( this.currentForm ).submit();
913                    this.formSubmitted = false;
914                } else if (!valid && this.pendingRequest === 0 && this.formSubmitted ) {
915                    $( this.currentForm ).triggerHandler( "invalid-form", [ this ]);
916                    this.formSubmitted = false;
917                }
918            },
919
920            previousValue: function( element ) {
921                return $.data( element, "previousValue" ) || $.data( element, "previousValue", {
922                    old: null,
923                    valid: true,
924                    message: this.defaultMessage( element, "remote" )
925                });
926            }
927
928        },
929
930        classRuleSettings: {
931            required: { required: true },
932            email: { email: true },
933            url: { url: true },
934            date: { date: true },
935            dateISO: { dateISO: true },
936            number: { number: true },
937            digits: { digits: true },
938            creditcard: { creditcard: true }
939        },
940
941        addClassRules: function( className, rules ) {
942            if ( className.constructor === String ) {
943                this.classRuleSettings[ className ] = rules;
944            } else {
945                $.extend( this.classRuleSettings, className );
946            }
947        },
948
949        classRules: function( element ) {
950            var rules = {},
951                classes = $( element ).attr( "class" );
952
953            if ( classes ) {
954                $.each( classes.split( " " ), function() {
955                    if ( this in $.validator.classRuleSettings ) {
956                        $.extend( rules, $.validator.classRuleSettings[ this ]);
957                    }
958                });
959            }
960            return rules;
961        },
962
963        attributeRules: function( element ) {
964            var rules = {},
965                $element = $( element ),
966                type = element.getAttribute( "type" ),
967                method, value;
968
969            for ( method in $.validator.methods ) {
970
971                // support for <input required> in both html5 and older browsers
972                if ( method === "required" ) {
973                    value = element.getAttribute( method );
974                    // Some browsers return an empty string for the required attribute
975                    // and non-HTML5 browsers might have required="" markup
976                    if ( value === "" ) {
977                        value = true;
978                    }
979                    // force non-HTML5 browsers to return bool
980                    value = !!value;
981                } else {
982                    value = $element.attr( method );
983                }
984
985                // convert the value to a number for number inputs, and for text for backwards compability
986                // allows type="date" and others to be compared as strings
987                if ( /min|max/.test( method ) && ( type === null || /number|range|text/.test( type ) ) ) {
988                    value = Number( value );
989                }
990
991                if ( value || value === 0 ) {
992                    rules[ method ] = value;
993                } else if ( type === method && type !== "range" ) {
994                    // exception: the jquery validate 'range' method
995                    // does not test for the html5 'range' type
996                    rules[ method ] = true;
997                }
998            }
999
1000            // maxlength may be returned as -1, 2147483647 ( IE ) and 524288 ( safari ) for text inputs
1001            if ( rules.maxlength && /-1|2147483647|524288/.test( rules.maxlength ) ) {
1002                delete rules.maxlength;
1003            }
1004
1005            return rules;
1006        },
1007
1008        dataRules: function( element ) {
1009            var method, value,
1010                rules = {}, $element = $( element );
1011            for ( method in $.validator.methods ) {
1012                value = $element.data( "rule" + method.charAt( 0 ).toUpperCase() + method.substring( 1 ).toLowerCase() );
1013                if ( value !== undefined ) {
1014                    rules[ method ] = value;
1015                }
1016            }
1017            return rules;
1018        },
1019
1020        staticRules: function( element ) {
1021            var rules = {},
1022                validator = $.data( element.form, "validator" );
1023            /*
1024
1025             console.log(validator);
1026             console.log(validator.settings);
1027             console.log(validator.settings.rules);
1028             console.log(typeof validator.settings.rules);
1029             console.log('-------------------');
1030             */
1031
1032            if ( typeof validator != 'undefined' && validator.settings.rules ) {
1033                rules = $.validator.normalizeRule( validator.settings.rules[ element.name ] ) || {};
1034            }
1035            return rules;
1036        },
1037
1038        normalizeRules: function( rules, element ) {
1039            // handle dependency check
1040            $.each( rules, function( prop, val ) {
1041                // ignore rule when param is explicitly false, eg. required:false
1042                if ( val === false ) {
1043                    delete rules[ prop ];
1044                    return;
1045                }
1046                if ( val.param || val.depends ) {
1047                    var keepRule = true;
1048                    switch ( typeof val.depends ) {
1049                        case "string":
1050                            keepRule = !!$( val.depends, element.form ).length;
1051                            break;
1052                        case "function":
1053                            keepRule = val.depends.call( element, element );
1054                            break;
1055                    }
1056                    if ( keepRule ) {
1057                        rules[ prop ] = val.param !== undefined ? val.param : true;
1058                    } else {
1059                        delete rules[ prop ];
1060                    }
1061                }
1062            });
1063
1064            // evaluate parameters
1065            $.each( rules, function( rule, parameter ) {
1066                rules[ rule ] = $.isFunction( parameter ) ? parameter( element ) : parameter;
1067            });
1068
1069            // clean number parameters
1070            $.each([ "minlength", "maxlength" ], function() {
1071                if ( rules[ this ] ) {
1072                    rules[ this ] = Number( rules[ this ] );
1073                }
1074            });
1075            $.each([ "rangelength", "range" ], function() {
1076                var parts;
1077                if ( rules[ this ] ) {
1078                    if ( $.isArray( rules[ this ] ) ) {
1079                        rules[ this ] = [ Number( rules[ this ][ 0 ]), Number( rules[ this ][ 1 ] ) ];
1080                    } else if ( typeof rules[ this ] === "string" ) {
1081                        parts = rules[ this ].replace(/[\[\]]/g, "" ).split( /[\s,]+/ );
1082                        rules[ this ] = [ Number( parts[ 0 ]), Number( parts[ 1 ] ) ];
1083                    }
1084                }
1085            });
1086
1087            if ( $.validator.autoCreateRanges ) {
1088                // auto-create ranges
1089                if ( rules.min != null && rules.max != null ) {
1090                    rules.range = [ rules.min, rules.max ];
1091                    delete rules.min;
1092                    delete rules.max;
1093                }
1094                if ( rules.minlength != null && rules.maxlength != null ) {
1095                    rules.rangelength = [ rules.minlength, rules.maxlength ];
1096                    delete rules.minlength;
1097                    delete rules.maxlength;
1098                }
1099            }
1100
1101            return rules;
1102        },
1103
1104        // Converts a simple string to a {string: true} rule, e.g., "required" to {required:true}
1105        normalizeRule: function( data ) {
1106            if ( typeof data === "string" ) {
1107                var transformed = {};
1108                $.each( data.split( /\s/ ), function() {
1109                    transformed[ this ] = true;
1110                });
1111                data = transformed;
1112            }
1113            return data;
1114        },
1115
1116        // http://jqueryvalidation.org/jQuery.validator.addMethod/
1117        addMethod: function( name, method, message ) {
1118            $.validator.methods[ name ] = method;
1119            $.validator.messages[ name ] = message !== undefined ? message : $.validator.messages[ name ];
1120            if ( method.length < 3 ) {
1121                $.validator.addClassRules( name, $.validator.normalizeRule( name ) );
1122            }
1123        },
1124
1125        methods: {
1126
1127            // http://jqueryvalidation.org/required-method/
1128            required: function( value, element, param ) {
1129                // check if dependency is met
1130                if ( !this.depend( param, element ) ) {
1131                    return "dependency-mismatch";
1132                }
1133                if ( element.nodeName.toLowerCase() === "select" ) {
1134                    // could be an array for select-multiple or a string, both are fine this way
1135                    var val = $( element ).val();
1136                    return val && val.length > 0;
1137                }
1138                if ( this.checkable( element ) ) {
1139                    return this.getLength( value, element ) > 0;
1140                }
1141                return $.trim( value ).length > 0;
1142            },
1143
1144            // http://jqueryvalidation.org/email-method/
1145            email: function( value, element ) {
1146                // From http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#e-mail-state-%28type=email%29
1147                // Retrieved 2014-01-14
1148                // If you have a problem with this implementation, report a bug against the above spec
1149                // Or use custom methods to implement your own email validation
1150                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 );
1151            },
1152
1153            // http://jqueryvalidation.org/url-method/
1154            url: function( value, element ) {
1155                // contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
1156                return this.optional( element ) || /^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test( value );
1157            },
1158
1159            // http://jqueryvalidation.org/date-method/
1160            date: function( value, element ) {
1161                return this.optional( element ) || !/Invalid|NaN/.test( new Date( value ).toString() );
1162            },
1163
1164            // http://jqueryvalidation.org/dateISO-method/
1165            dateISO: function( value, element ) {
1166                return this.optional( element ) || /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test( value );
1167            },
1168
1169            // http://jqueryvalidation.org/number-method/
1170            number: function( value, element ) {
1171                return this.optional( element ) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test( value );
1172            },
1173
1174            // http://jqueryvalidation.org/digits-method/
1175            digits: function( value, element ) {
1176                return this.optional( element ) || /^\d+$/.test( value );
1177            },
1178
1179            // http://jqueryvalidation.org/creditcard-method/
1180            // based on http://en.wikipedia.org/wiki/Luhn/
1181            creditcard: function( value, element ) {
1182                if ( this.optional( element ) ) {
1183                    return "dependency-mismatch";
1184                }
1185                // accept only spaces, digits and dashes
1186                if ( /[^0-9 \-]+/.test( value ) ) {
1187                    return false;
1188                }
1189                var nCheck = 0,
1190                    nDigit = 0,
1191                    bEven = false,
1192                    n, cDigit;
1193
1194                value = value.replace( /\D/g, "" );
1195
1196                // Basing min and max length on
1197                // http://developer.ean.com/general_info/Valid_Credit_Card_Types
1198                if ( value.length < 13 || value.length > 19 ) {
1199                    return false;
1200                }
1201
1202                for ( n = value.length - 1; n >= 0; n--) {
1203                    cDigit = value.charAt( n );
1204                    nDigit = parseInt( cDigit, 10 );
1205                    if ( bEven ) {
1206                        if ( ( nDigit *= 2 ) > 9 ) {
1207                            nDigit -= 9;
1208                        }
1209                    }
1210                    nCheck += nDigit;
1211                    bEven = !bEven;
1212                }
1213
1214                return ( nCheck % 10 ) === 0;
1215            },
1216
1217            // http://jqueryvalidation.org/minlength-method/
1218            minlength: function( value, element, param ) {
1219                var length = $.isArray( value ) ? value.length : this.getLength( value, element );
1220                return this.optional( element ) || length >= param;
1221            },
1222
1223            // http://jqueryvalidation.org/maxlength-method/
1224            maxlength: function( value, element, param ) {
1225                var length = $.isArray( value ) ? value.length : this.getLength( value, element );
1226                return this.optional( element ) || length <= param;
1227            },
1228
1229            // http://jqueryvalidation.org/rangelength-method/
1230            rangelength: function( value, element, param ) {
1231                var length = $.isArray( value ) ? value.length : this.getLength( value, element );
1232                return this.optional( element ) || ( length >= param[ 0 ] && length <= param[ 1 ] );
1233            },
1234
1235            // http://jqueryvalidation.org/min-method/
1236            min: function( value, element, param ) {
1237                return this.optional( element ) || value >= param;
1238            },
1239
1240            // http://jqueryvalidation.org/max-method/
1241            max: function( value, element, param ) {
1242                return this.optional( element ) || value <= param;
1243            },
1244
1245            // http://jqueryvalidation.org/range-method/
1246            range: function( value, element, param ) {
1247                return this.optional( element ) || ( value >= param[ 0 ] && value <= param[ 1 ] );
1248            },
1249
1250            // http://jqueryvalidation.org/equalTo-method/
1251            equalTo: function( value, element, param ) {
1252                // bind to the blur event of the target in order to revalidate whenever the target field is updated
1253                // TODO find a way to bind the event just once, avoiding the unbind-rebind overhead
1254                var target = $( param );
1255                if ( this.settings.onfocusout ) {
1256                    target.unbind( ".validate-equalTo" ).bind( "blur.validate-equalTo", function() {
1257                        $( element ).valid();
1258                    });
1259                }
1260                return value === target.val();
1261            },
1262
1263            // http://jqueryvalidation.org/remote-method/
1264            remote: function( value, element, param ) {
1265                if ( this.optional( element ) ) {
1266                    return "dependency-mismatch";
1267                }
1268
1269                var previous = this.previousValue( element ),
1270                    validator, data;
1271
1272                if (!this.settings.messages[ element.name ] ) {
1273                    this.settings.messages[ element.name ] = {};
1274                }
1275                previous.originalMessage = this.settings.messages[ element.name ].remote;
1276                this.settings.messages[ element.name ].remote = previous.message;
1277
1278                param = typeof param === "string" && { url: param } || param;
1279
1280                if ( previous.old === value ) {
1281                    return previous.valid;
1282                }
1283
1284                previous.old = value;
1285                validator = this;
1286                this.startRequest( element );
1287                data = {};
1288                data[ element.name ] = value;
1289                $.ajax( $.extend( true, {
1290                    url: param,
1291                    mode: "abort",
1292                    port: "validate" + element.name,
1293                    dataType: "json",
1294                    data: data,
1295                    context: validator.currentForm,
1296                    success: function( response ) {
1297                        var valid = response === true || response === "true",
1298                            errors, message, submitted;
1299
1300                        validator.settings.messages[ element.name ].remote = previous.originalMessage;
1301                        if ( valid ) {
1302                            submitted = validator.formSubmitted;
1303                            validator.prepareElement( element );
1304                            validator.formSubmitted = submitted;
1305                            validator.successList.push( element );
1306                            delete validator.invalid[ element.name ];
1307                            validator.showErrors();
1308                        } else {
1309                            errors = {};
1310                            message = response || validator.defaultMessage( element, "remote" );
1311                            errors[ element.name ] = previous.message = $.isFunction( message ) ? message( value ) : message;
1312                            validator.invalid[ element.name ] = true;
1313                            validator.showErrors( errors );
1314                        }
1315                        previous.valid = valid;
1316                        validator.stopRequest( element, valid );
1317                    }
1318                }, param ) );
1319                return "pending";
1320            }
1321
1322        }
1323
1324    });
1325
1326    $.format = function deprecated() {
1327        throw "$.format has been deprecated. Please use $.validator.format instead.";
1328    };
1329
1330// ajax mode: abort
1331// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
1332// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
1333
1334    var pendingRequests = {},
1335        ajax;
1336// Use a prefilter if available (1.5+)
1337    if ( $.ajaxPrefilter ) {
1338        $.ajaxPrefilter(function( settings, _, xhr ) {
1339            var port = settings.port;
1340            if ( settings.mode === "abort" ) {
1341                if ( pendingRequests[port] ) {
1342                    pendingRequests[port].abort();
1343                }
1344                pendingRequests[port] = xhr;
1345            }
1346        });
1347    } else {
1348        // Proxy ajax
1349        ajax = $.ajax;
1350        $.ajax = function( settings ) {
1351            var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode,
1352                port = ( "port" in settings ? settings : $.ajaxSettings ).port;
1353            if ( mode === "abort" ) {
1354                if ( pendingRequests[port] ) {
1355                    pendingRequests[port].abort();
1356                }
1357                pendingRequests[port] = ajax.apply(this, arguments);
1358                return pendingRequests[port];
1359            }
1360            return ajax.apply(this, arguments);
1361        };
1362    }
1363
1364// provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation
1365// handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target
1366
1367    $.extend($.fn, {
1368        validateDelegate: function( delegate, type, handler ) {
1369            return this.bind(type, function( event ) {
1370                var target = $(event.target);
1371                if ( target.is(delegate) ) {
1372                    return handler.apply(target, arguments);
1373                }
1374            });
1375        }
1376    });
1377
1378}));

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.