PageSourceSearch

https://sis.glemt.org.br/Base/Tema/Vendor/Pixel/1.3.0/libs/jquery/…/1.13.0/additional-methods.js

js glemt.org.br collected 2026-09-27 08:15:24 UTC 19,160 bytes, 470 lines download raw bytes

vendor: 5,809 bytes, lines 1-163
1/*!
2 * jQuery Validation Plugin v1.13.0
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", "./jquery.validate"], factory);
12    } else {
13        factory(jQuery);
14    }
15}(function ($) {
16
17    (function () {
18
19        function stripHtml(value) {
20            // remove html tags and space chars
21            return value.replace(/<.[^<>]*?>/g, " ").replace(/&nbsp;|&#160;/gi, " ")
22                    // remove punctuation
23                    .replace(/[.(),;:!?%#$'\"_+=\/\-“”’]*/g, "");
24        }
25
26        $.validator.addMethod("maxWords", function (value, element, params) {
27            return this.optional(element) || stripHtml(value).match(/\b\w+\b/g).length <= params;
28        }, $.validator.format("Please enter {0} words or less."));
29
30        $.validator.addMethod("minWords", function (value, element, params) {
31            return this.optional(element) || stripHtml(value).match(/\b\w+\b/g).length >= params;
32        }, $.validator.format("Please enter at least {0} words."));
33
34        $.validator.addMethod("rangeWords", function (value, element, params) {
35            var valueStripped = stripHtml(value),
36                    regex = /\b\w+\b/g;
37            return this.optional(element) || valueStripped.match(regex).length >= params[0] && valueStripped.match(regex).length <= params[1];
38        }, $.validator.format("Please enter between {0} and {1} words."));
39
40    }());
41
42    $.validator.addMethod("alphanumeric", function (value, element) {
43        return this.optional(element) || /^\w+$/i.test(value);
44    }, "Letters, numbers, and underscores only please");
45
46    /* NOTICE: Modified version of Castle.Components.Validator.CreditCardValidator
47     * Redistributed under the the Apache License 2.0 at http://www.apache.org/licenses/LICENSE-2.0
48     * Valid Types: mastercard, visa, amex, dinersclub, enroute, discover, jcb, unknown, all (overrides all other settings)
49     */
50    $.validator.addMethod("creditcardtypes", function (value, element, param) {
51        if (/[^0-9\-]+/.test(value)) {
52            return false;
53        }
54
55        value = value.replace(/\D/g, "");
56
57        var validTypes = 0x0000;
58
59        if (param.mastercard) {
60            validTypes |= 0x0001;
61        }
62        if (param.visa) {
63            validTypes |= 0x0002;
64        }
65        if (param.amex) {
66            validTypes |= 0x0004;
67        }
68        if (param.dinersclub) {
69            validTypes |= 0x0008;
70        }
71        if (param.enroute) {
72            validTypes |= 0x0010;
73        }
74        if (param.discover) {
75            validTypes |= 0x0020;
76        }
77        if (param.jcb) {
78            validTypes |= 0x0040;
79        }
80        if (param.unknown) {
81            validTypes |= 0x0080;
82        }
83        if (param.all) {
84            validTypes = 0x0001 | 0x0002 | 0x0004 | 0x0008 | 0x0010 | 0x0020 | 0x0040 | 0x0080;
85        }
86        if (validTypes & 0x0001 && /^(5[12345])/.test(value)) { //mastercard
87            return value.length === 16;
88        }
89        if (validTypes & 0x0002 && /^(4)/.test(value)) { //visa
90            return value.length === 16;
91        }
92        if (validTypes & 0x0004 && /^(3[47])/.test(value)) { //amex
93            return value.length === 15;
94        }
95        if (validTypes & 0x0008 && /^(3(0[012345]|[68]))/.test(value)) { //dinersclub
96            return value.length === 14;
97        }
98        if (validTypes & 0x0010 && /^(2(014|149))/.test(value)) { //enroute
99            return value.length === 15;
100        }
101        if (validTypes & 0x0020 && /^(6011)/.test(value)) { //discover
102            return value.length === 16;
103        }
104        if (validTypes & 0x0040 && /^(3)/.test(value)) { //jcb
105            return value.length === 16;
106        }
107        if (validTypes & 0x0040 && /^(2131|1800)/.test(value)) { //jcb
108            return value.length === 15;
109        }
110        if (validTypes & 0x0080) { //unknown
111            return true;
112        }
113        return false;
114    }, "Please enter a valid credit card number.");
115
116    /**
117     * Validates currencies with any given symbols by @jameslouiz
118     * Symbols can be optional or required. Symbols required by default
119     *
120     * Usage examples:
121     *  currency: ["£", false] - Use false for soft currency validation
122     *  currency: ["$", false]
123     *  currency: ["RM", false] - also works with text based symbols such as "RM" - Malaysia Ringgit etc
124     *
125     *  <input class="currencyInput" name="currencyInput">
126     *
127     * Soft symbol checking
128     *  currencyInput: {
129     *     currency: ["$", false]
130     *  }
131     *
132     * Strict symbol checking (default)
133     *  currencyInput: {
134     *     currency: "$"
135     *     //OR
136     *     currency: ["$", true]
137     *  }
138     *
139     * Multiple Symbols
140     *  currencyInput: {
141     *     currency: "$,£,¢"
142     *  }
143     */
144    $.validator.addMethod("currency", function (value, element, param) {
145        var isParamString = typeof param === "string",
146                symbol = isParamString ? param : param[0],
147                soft = isParamString ? true : param[1],
148                regex;
149
150        symbol = symbol.replace(/,/g, "");
151        symbol = soft ? symbol + "]" : symbol + "]?";
152        regex = "^[" + symbol + "([1-9]{1}[0-9]{0,2}(\\,[0-9]{3})*(\\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\\.[0-9]{0,2})?|0(\\.[0-9]{0,2})?|(\\.[0-9]{1,2})?)$";
153        regex = new RegExp(regex);
154        return this.optional(element) || regex.test(value);
155
156    }, "Please specify a valid currency");
157
158    $.validator.addMethod("integer", function (value, element) {
159        return this.optional(element) || /^-?\d+$/.test(value);
160    }, "A positive or negative non-decimal number please");
161
162
163    /*
164     * Lets you say "at least X inputs that match selector Y must be filled."
165     *
166     * The end result is that neither of these inputs:
167     *
168     *	<input class="productinfo" name="partnumber">
169     *	<input class="productinfo" name="description">
170     *
171     *	...will validate unless at least one of them is filled.
172     *
173     * partnumber:	{require_from_group: [1,".productinfo"]},
174     * description: {require_from_group: [1,".productinfo"]}
175     *
176     * options[0]: number of fields that must be filled in the group
177     * options[1]: CSS selector that defines the group of conditionally required fields
178     */
179    $.validator.addMethod("require_from_group", function (value, element, options) {
180        var $fields = $(options[1], element.form),
181                $fieldsFirst = $fields.eq(0),
182                validator = $fieldsFirst.data("valid_req_grp") ? $fieldsFirst.data("valid_req_grp") : $.extend({}, this),
183                isValid = $fields.filter(function () {
184                    return validator.elementValue(this);
185                }).length >= options[0];
186
187        // Store the cloned validator for future validation
188        $fieldsFirst.data("valid_req_grp", validator);
189
190        // If element isn't being validated, run each require_from_group field's validation rules
191        if (!$(element).data("being_validated")) {
192            $fields.data("being_validated", true);
193            $fields.each(function () {
194                validator.element(this);
195            });
196            $fields.data("being_validated", false);
197        }
198        return isValid;
199    }, $.validator.format("Please fill at least {0} of these fields."));
200
201    /*
202     * Lets you say "either at least X inputs that match selector Y must be filled,
203     * OR they must all be skipped (left blank)."
204     *
205     * The end result, is that none of these inputs:
206     *
207     *	<input class="productinfo" name="partnumber">
208     *	<input class="productinfo" name="description">
209     *	<input class="productinfo" name="color">
210     *
211     *	...will validate unless either at least two of them are filled,
212     *	OR none of them are.
213     *
214     * partnumber:	{skip_or_fill_minimum: [2,".productinfo"]},
215     * description: {skip_or_fill_minimum: [2,".productinfo"]},
216     * color:		{skip_or_fill_minimum: [2,".productinfo"]}
217     *
218     * options[0]: number of fields that must be filled in the group
219     * options[1]: CSS selector that defines the group of conditionally required fields
220     *
221     */
222    $.validator.addMethod("skip_or_fill_minimum", function (value, element, options) {
223        var $fields = $(options[1], element.form),
224                $fieldsFirst = $fields.eq(0),
225                validator = $fieldsFirst.data("valid_skip") ? $fieldsFirst.data("valid_skip") : $.extend({}, this),
226                numberFilled = $fields.filter(function () {
227                    return validator.elementValue(this);
228                }).length,
229                isValid = numberFilled === 0 || numberFilled >= options[0];
230
231        // Store the cloned validator for future validation
232        $fieldsFirst.data("valid_skip", validator);
233
234        // If element isn't being validated, run each skip_or_fill_minimum field's validation rules
235        if (!$(element).data("being_validated")) {
236            $fields.data("being_validated", true);
237            $fields.each(function () {
238                validator.element(this);
239            });
240            $fields.data("being_validated", false);
241        }
242        return isValid;
243    }, $.validator.format("Please either skip these fields or fill at least {0} of them."));
244
245    /* Validates US States and/or Territories by @jdforsythe
246     * Can be case insensitive or require capitalization - default is case insensitive
247     * Can include US Territories or not - default does not
248     * Can include US Military postal abbreviations (AA, AE, AP) - default does not
249     *
250     * Note: "States" always includes DC (District of Colombia)
251     *
252     * Usage examples:
253     *
254     *  This is the default - case insensitive, no territories, no military zones
255     *  stateInput: {
256     *     caseSensitive: false,
257     *     includeTerritories: false,
258     *     includeMilitary: false
259     *  }
260     *
261     *  Only allow capital letters, no territories, no military zones
262     *  stateInput: {
263     *     caseSensitive: false
264     *  }
265     *
266     *  Case insensitive, include territories but not military zones
267     *  stateInput: {
268     *     includeTerritories: true
269     *  }
270     *
271     *  Only allow capital letters, include territories and military zones
272     *  stateInput: {
273     *     caseSensitive: true,
274     *     includeTerritories: true,
275     *     includeMilitary: true
276     *  }
277     *
278     *
279     *
280     */
281
282// same as url, but TLD is optional
283    $.validator.addMethod("url2", function (value, element) {
284        return this.optional(element) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);
285    }, $.validator.messages.url);
286
287    $.validator.addMethod("dateBR", function (value, element) {
288        //contando chars    
289        if (value.length != 10)
290            return (this.optional(element) || false);
291        // verificando data
292        var data = value;
293        var dia = data.substr(0, 2);
294        var barra1 = data.substr(2, 1);
295        var mes = data.substr(3, 2);
296        var barra2 = data.substr(5, 1);
297        var ano = data.substr(6, 4);
298        if (data.length != 10 || barra1 != "/" || barra2 != "/" || isNaN(dia) || isNaN(mes) || isNaN(ano) || dia > 31 || mes > 12)
299            return (this.optional(element) || false);
300        if ((mes == 4 || mes == 6 || mes == 9 || mes == 11) && dia == 31)
301            return (this.optional(element) || false);
302        if (mes == 2 && (dia > 29 || (dia == 29 && ano % 4 != 0)))
303            return (this.optional(element) || false);
304        if (ano < 1900)
305            return (this.optional(element) || false);
306        return (this.optional(element) || true);
307    }, "Informe uma data válida");  // Mensagem padrão 
308
309    $.validator.addMethod("timeBR", function (value, element) {
310        if (value.length != 8)
311            return false;
312        var data = value;
313        var hor = data.substr(0, 2);
314        var se1 = data.substr(2, 1);
315        var min = data.substr(3, 2);
316        var se2 = data.substr(5, 1);
317        var seg = data.substr(6, 2);
318        if (data.length != 8 || se1 != ':' || se2 != ':' || isNaN(hor) || isNaN(min) || isNaN(seg)) {
319            return false;
320        }
321        if (!((hor >= 0 && hor <= 23) && (min >= 0 && min <= 59) && (seg >= 0 && seg <= 59))) {
322            return false;
323        }
324        return true;
325    }, "Informe uma hora válida");
326
327    $.validator.addMethod("cep", function (e, t) {        
328        return this.optional(t) || /^\d{2}.\d{3}-\d{3}?$/.test(e);
329    }, "Informe um CEP válido");
330
331    $.validator.addMethod("datetimeBR", function (value, element) {
332        //contando chars
333        if (value.length != 16)
334            return (this.optional(element) || false);
335        // dividindo data e hora
336        if (value.substr(10, 1) != ' ')
337            return (this.optional(element) || false); // verificando se há espaço
338        var arrOpcoes = value.split(' ');
339        if (arrOpcoes.length != 2)
340            return (this.optional(element) || false); // verificando a divisão de data e hora
341        // verificando data
342        var data = arrOpcoes[0];
343        var dia = data.substr(0, 2);
344        var barra1 = data.substr(2, 1);
345        var mes = data.substr(3, 2);
346        var barra2 = data.substr(5, 1);
347        var ano = data.substr(6, 4);
348        if (data.length != 10 || barra1 != "/" || barra2 != "/" || isNaN(dia) || isNaN(mes) || isNaN(ano) || dia > 31 || mes > 12)
349            return (this.optional(element) || false);
350        if ((mes == 4 || mes == 6 || mes == 9 || mes == 11) && dia == 31)
351            return (this.optional(element) || false);
352        if (mes == 2 && (dia > 29 || (dia == 29 && ano % 4 != 0)))
353            return (this.optional(element) || false);
354        // verificando hora
355        var horario = arrOpcoes[1];
356        var hora = horario.substr(0, 2);
357        var doispontos = horario.substr(2, 1);
358        var minuto = horario.substr(3, 2);
359        if (horario.length != 5 || isNaN(hora) || isNaN(minuto) || hora > 23 || minuto > 59 || doispontos != ":")
360            return (this.optional(element) || false);
361        return this.optional(element) || true;
362    }, "Informe uma data e hora válidos");
363
364    $.validator.addMethod("celular", function (value, element) {
365        value = value.replace("(", "");
366        value = value.replace(")", "");
367        value = value.replace("-", "");
368        value = value.replace("_", "");
369        value = value.replace(" ", "");
370        return this.optional(element) || /[0-9]{10}/.test(value) || /[0-9]{11}/.test(value);
371    }, "Informe um celular válido");
372
373    $.validator.addMethod("cnpj", function (cnpj, element) {
374        cnpj = jQuery.trim(cnpj);
375        // DEIXA APENAS OS NÚMEROS
376        cnpj = cnpj.replace('/', '');
377        cnpj = cnpj.replace('.', '');
378        cnpj = cnpj.replace('.', '');
379        cnpj = cnpj.replace('-', '');
380
381        var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
382        digitos_iguais = 1;
383
384        if (cnpj.length < 14 && cnpj.length < 15) {
385            return this.optional(element) || false;
386        }
387        for (i = 0; i < cnpj.length - 1; i++) {
388            if (cnpj.charAt(i) != cnpj.charAt(i + 1)) {
389                digitos_iguais = 0;
390                break;
391            }
392        }
393
394        if (!digitos_iguais) {
395            tamanho = cnpj.length - 2
396            numeros = cnpj.substring(0, tamanho);
397            digitos = cnpj.substring(tamanho);
398            soma = 0;
399            pos = tamanho - 7;
400
401            for (i = tamanho; i >= 1; i--) {
402                soma += numeros.charAt(tamanho - i) * pos--;
403                if (pos < 2) {
404                    pos = 9;
405                }
406            }
407            resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
408            if (resultado != digitos.charAt(0)) {
409                return this.optional(element) || false;
410            }
411            tamanho = tamanho + 1;
412            numeros = cnpj.substring(0, tamanho);
413            soma = 0;
414            pos = tamanho - 7;
415            for (i = tamanho; i >= 1; i--) {
416                soma += numeros.charAt(tamanho - i) * pos--;
417                if (pos < 2) {
418                    pos = 9;
419                }
420            }
421            resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
422            if (resultado != digitos.charAt(1)) {
423                return this.optional(element) || false;
424            }
425            return this.optional(element) || true;
426        } else {
427            return this.optional(element) || false;
428        }
429    }, "Informe um CNPJ válido");
430
431    $.validator.addMethod("cpf", function (value, element) {
432        value = jQuery.trim(value);
433        value = value.replace('.', '');
434        value = value.replace('.', '');
435        cpf = value.replace('-', '');
436        while (cpf.length < 11)
437            cpf = "0" + cpf;
438        var expReg = /^0+$|^1+$|^2+$|^3+$|^4+$|^5+$|^6+$|^7+$|^8+$|^9+$/;
439        var a = [];
440        var b = new Number;
441        var c = 11;
442        for (i = 0; i < 11; i++) {
443            a[i] = cpf.charAt(i);
444            if (i < 9)
445                b += (a[i] * --c);
446        }
447        if ((x = b % 11) < 2) {
448            a[9] = 0
449        } else {
450            a[9] = 11 - x
451        }
452        b = 0;
453        c = 11;
454        for (y = 0; y < 10; y++)
455            b += (a[y] * c--);
456        if ((x = b % 11) < 2) {
457            a[10] = 0;
458        } else {
459            a[10] = 11 - x;
460        }
461        if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10]) || cpf.match(expReg))
462            return this.optional(element) || false;
463        return this.optional(element) || true;
464    }, "Informe um CPF válido"); // Mensagem padrão 
465
466    $.validator.addMethod("notequal", function (value, element, param) {
467        return this.optional(element) || (value == $(param).val() ? false : true);
468    }, "Este valor não pode ser igual"); // Mensagem padrão 
469
470}));

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.