annotate Agendas/trunk/src/Agendas.Web/Scripts/jquery.validate-vsdoc.js @ 217:c4c60e034103 deploy 2011-09-06

sugerencia de recordatorios
author nelopauselli
date Tue, 06 Sep 2011 18:09:43 -0300
parents c62b77fc33f4
children
rev   line source
10
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1 /*
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
2 * This file has been commented to support Visual Studio Intellisense.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
3 * You should not use this file at runtime inside the browser--it is only
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
4 * intended to be used only for design-time IntelliSense. Please use the
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
5 * standard jQuery library for all production use.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
6 *
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
7 * Comment version: 1.7
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
8 */
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
9
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
10 /*
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
11 * Note: While Microsoft is not the author of this file, Microsoft is
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
12 * offering you a license subject to the terms of the Microsoft Software
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
13 * License Terms for Microsoft ASP.NET Model View Controller 3.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
14 * Microsoft reserves all other rights. The notices below are provided
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
15 * for informational purposes only and are not the license terms under
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
16 * which Microsoft distributed this file.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
17 *
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
18 * jQuery validation plug-in 1.7
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
19 *
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
20 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
21 * http://docs.jquery.com/Plugins/Validation
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
22 *
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
23 * Copyright (c) 2006 - 2008 Jörn Zaefferer
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
24 *
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
25 * $Id: jquery.validate.js 6403 2009-06-17 14:27:16Z joern.zaefferer $
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
26 *
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
27 */
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
28
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
29 (function($) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
30
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
31 $.extend($.fn, {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
32 // http://docs.jquery.com/Plugins/Validation/validate
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
33 validate: function( options ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
34 /// <summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
35 /// Validates the selected form. This method sets up event handlers for submit, focus,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
36 /// keyup, blur and click to trigger validation of the entire form or individual
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
37 /// elements. Each one can be disabled, see the onxxx options (onsubmit, onfocusout,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
38 /// onkeyup, onclick). focusInvalid focuses elements when submitting a invalid form.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
39 /// </summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
40 /// <param name="options" type="Options">
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
41 /// A set of key/value pairs that configure the validate. All options are optional.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
42 /// </param>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
43 /// <returns type="Validator" />
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
44
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
45 // if nothing is selected, return nothing; can't chain anyway
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
46 if (!this.length) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
47 options && options.debug && window.console && console.warn( "nothing selected, can't validate, returning nothing" );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
48 return;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
49 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
50
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
51 // check if a validator for this form was already created
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
52 var validator = $.data(this[0], 'validator');
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
53 if ( validator ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
54 return validator;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
55 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
56
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
57 validator = new $.validator( options, this[0] );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
58 $.data(this[0], 'validator', validator);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
59
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
60 if ( validator.settings.onsubmit ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
61
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
62 // allow suppresing validation by adding a cancel class to the submit button
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
63 this.find("input, button").filter(".cancel").click(function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
64 validator.cancelSubmit = true;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
65 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
66
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
67 // when a submitHandler is used, capture the submitting button
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
68 if (validator.settings.submitHandler) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
69 this.find("input, button").filter(":submit").click(function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
70 validator.submitButton = this;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
71 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
72 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
73
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
74 // validate the form on submit
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
75 this.submit( function( event ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
76 if ( validator.settings.debug )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
77 // prevent form submit to be able to see console output
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
78 event.preventDefault();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
79
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
80 function handle() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
81 if ( validator.settings.submitHandler ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
82 if (validator.submitButton) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
83 // insert a hidden input as a replacement for the missing submit button
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
84 var hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
85 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
86 validator.settings.submitHandler.call( validator, validator.currentForm );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
87 if (validator.submitButton) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
88 // and clean up afterwards; thanks to no-block-scope, hidden can be referenced
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
89 hidden.remove();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
90 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
91 return false;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
92 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
93 return true;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
94 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
95
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
96 // prevent submit for invalid forms or custom submit handlers
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
97 if ( validator.cancelSubmit ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
98 validator.cancelSubmit = false;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
99 return handle();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
100 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
101 if ( validator.form() ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
102 if ( validator.pendingRequest ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
103 validator.formSubmitted = true;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
104 return false;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
105 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
106 return handle();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
107 } else {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
108 validator.focusInvalid();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
109 return false;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
110 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
111 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
112 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
113
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
114 return validator;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
115 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
116 // http://docs.jquery.com/Plugins/Validation/valid
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
117 valid: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
118 /// <summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
119 /// Checks if the selected form is valid or if all selected elements are valid.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
120 /// validate() needs to be called on the form before checking it using this method.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
121 /// </summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
122 /// <returns type="Boolean" />
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
123
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
124 if ( $(this[0]).is('form')) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
125 return this.validate().form();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
126 } else {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
127 var valid = true;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
128 var validator = $(this[0].form).validate();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
129 this.each(function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
130 valid &= validator.element(this);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
131 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
132 return valid;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
133 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
134 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
135 // attributes: space seperated list of attributes to retrieve and remove
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
136 removeAttrs: function(attributes) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
137 /// <summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
138 /// Remove the specified attributes from the first matched element and return them.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
139 /// </summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
140 /// <param name="attributes" type="String">
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
141 /// A space-seperated list of attribute names to remove.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
142 /// </param>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
143 /// <returns type="" />
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
144
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
145 var result = {},
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
146 $element = this;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
147 $.each(attributes.split(/\s/), function(index, value) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
148 result[value] = $element.attr(value);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
149 $element.removeAttr(value);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
150 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
151 return result;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
152 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
153 // http://docs.jquery.com/Plugins/Validation/rules
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
154 rules: function(command, argument) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
155 /// <summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
156 /// Return the validations rules for the first selected element.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
157 /// </summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
158 /// <param name="command" type="String">
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
159 /// Can be either "add" or "remove".
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
160 /// </param>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
161 /// <param name="argument" type="">
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
162 /// A list of rules to add or remove.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
163 /// </param>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
164 /// <returns type="" />
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
165
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
166 var element = this[0];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
167
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
168 if (command) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
169 var settings = $.data(element.form, 'validator').settings;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
170 var staticRules = settings.rules;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
171 var existingRules = $.validator.staticRules(element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
172 switch(command) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
173 case "add":
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
174 $.extend(existingRules, $.validator.normalizeRule(argument));
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
175 staticRules[element.name] = existingRules;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
176 if (argument.messages)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
177 settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
178 break;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
179 case "remove":
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
180 if (!argument) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
181 delete staticRules[element.name];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
182 return existingRules;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
183 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
184 var filtered = {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
185 $.each(argument.split(/\s/), function(index, method) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
186 filtered[method] = existingRules[method];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
187 delete existingRules[method];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
188 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
189 return filtered;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
190 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
191 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
192
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
193 var data = $.validator.normalizeRules(
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
194 $.extend(
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
195 {},
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
196 $.validator.metadataRules(element),
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
197 $.validator.classRules(element),
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
198 $.validator.attributeRules(element),
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
199 $.validator.staticRules(element)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
200 ), element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
201
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
202 // make sure required is at front
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
203 if (data.required) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
204 var param = data.required;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
205 delete data.required;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
206 data = $.extend({required: param}, data);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
207 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
208
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
209 return data;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
210 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
211 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
212
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
213 // Custom selectors
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
214 $.extend($.expr[":"], {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
215 // http://docs.jquery.com/Plugins/Validation/blank
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
216 blank: function(a) {return !$.trim("" + a.value);},
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
217 // http://docs.jquery.com/Plugins/Validation/filled
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
218 filled: function(a) {return !!$.trim("" + a.value);},
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
219 // http://docs.jquery.com/Plugins/Validation/unchecked
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
220 unchecked: function(a) {return !a.checked;}
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
221 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
222
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
223 // constructor for validator
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
224 $.validator = function( options, form ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
225 this.settings = $.extend( true, {}, $.validator.defaults, options );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
226 this.currentForm = form;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
227 this.init();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
228 };
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
229
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
230 $.validator.format = function(source, params) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
231 /// <summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
232 /// Replaces {n} placeholders with arguments.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
233 /// One or more arguments can be passed, in addition to the string template itself, to insert
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
234 /// into the string.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
235 /// </summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
236 /// <param name="source" type="String">
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
237 /// The string to format.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
238 /// </param>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
239 /// <param name="params" type="String">
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
240 /// The first argument to insert, or an array of Strings to insert
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
241 /// </param>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
242 /// <returns type="String" />
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
243
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
244 if ( arguments.length == 1 )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
245 return function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
246 var args = $.makeArray(arguments);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
247 args.unshift(source);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
248 return $.validator.format.apply( this, args );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
249 };
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
250 if ( arguments.length > 2 && params.constructor != Array ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
251 params = $.makeArray(arguments).slice(1);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
252 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
253 if ( params.constructor != Array ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
254 params = [ params ];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
255 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
256 $.each(params, function(i, n) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
257 source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
258 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
259 return source;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
260 };
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
261
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
262 $.extend($.validator, {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
263
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
264 defaults: {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
265 messages: {},
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
266 groups: {},
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
267 rules: {},
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
268 errorClass: "error",
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
269 validClass: "valid",
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
270 errorElement: "label",
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
271 focusInvalid: true,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
272 errorContainer: $( [] ),
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
273 errorLabelContainer: $( [] ),
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
274 onsubmit: true,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
275 ignore: [],
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
276 ignoreTitle: false,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
277 onfocusin: function(element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
278 this.lastActive = element;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
279
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
280 // hide error label and remove error class on focus if enabled
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
281 if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
282 this.settings.unhighlight && this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
283 this.errorsFor(element).hide();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
284 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
285 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
286 onfocusout: function(element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
287 if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
288 this.element(element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
289 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
290 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
291 onkeyup: function(element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
292 if ( element.name in this.submitted || element == this.lastElement ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
293 this.element(element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
294 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
295 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
296 onclick: function(element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
297 // click on selects, radiobuttons and checkboxes
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
298 if ( element.name in this.submitted )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
299 this.element(element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
300 // or option elements, check parent select in that case
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
301 else if (element.parentNode.name in this.submitted)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
302 this.element(element.parentNode);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
303 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
304 highlight: function( element, errorClass, validClass ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
305 $(element).addClass(errorClass).removeClass(validClass);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
306 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
307 unhighlight: function( element, errorClass, validClass ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
308 $(element).removeClass(errorClass).addClass(validClass);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
309 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
310 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
311
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
312 // http://docs.jquery.com/Plugins/Validation/Validator/setDefaults
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
313 setDefaults: function(settings) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
314 /// <summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
315 /// Modify default settings for validation.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
316 /// Accepts everything that Plugins/Validation/validate accepts.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
317 /// </summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
318 /// <param name="settings" type="Options">
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
319 /// Options to set as default.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
320 /// </param>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
321 /// <returns type="undefined" />
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
322
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
323 $.extend( $.validator.defaults, settings );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
324 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
325
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
326 messages: {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
327 required: "This field is required.",
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
328 remote: "Please fix this field.",
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
329 email: "Please enter a valid email address.",
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
330 url: "Please enter a valid URL.",
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
331 date: "Please enter a valid date.",
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
332 dateISO: "Please enter a valid date (ISO).",
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
333 number: "Please enter a valid number.",
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
334 digits: "Please enter only digits.",
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
335 creditcard: "Please enter a valid credit card number.",
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
336 equalTo: "Please enter the same value again.",
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
337 accept: "Please enter a value with a valid extension.",
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
338 maxlength: $.validator.format("Please enter no more than {0} characters."),
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
339 minlength: $.validator.format("Please enter at least {0} characters."),
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
340 rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."),
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
341 range: $.validator.format("Please enter a value between {0} and {1}."),
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
342 max: $.validator.format("Please enter a value less than or equal to {0}."),
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
343 min: $.validator.format("Please enter a value greater than or equal to {0}.")
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
344 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
345
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
346 autoCreateRanges: false,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
347
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
348 prototype: {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
349
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
350 init: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
351 this.labelContainer = $(this.settings.errorLabelContainer);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
352 this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
353 this.containers = $(this.settings.errorContainer).add( this.settings.errorLabelContainer );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
354 this.submitted = {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
355 this.valueCache = {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
356 this.pendingRequest = 0;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
357 this.pending = {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
358 this.invalid = {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
359 this.reset();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
360
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
361 var groups = (this.groups = {});
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
362 $.each(this.settings.groups, function(key, value) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
363 $.each(value.split(/\s/), function(index, name) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
364 groups[name] = key;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
365 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
366 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
367 var rules = this.settings.rules;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
368 $.each(rules, function(key, value) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
369 rules[key] = $.validator.normalizeRule(value);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
370 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
371
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
372 function delegate(event) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
373 var validator = $.data(this[0].form, "validator"),
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
374 eventType = "on" + event.type.replace(/^validate/, "");
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
375 validator.settings[eventType] && validator.settings[eventType].call(validator, this[0] );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
376 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
377 $(this.currentForm)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
378 .validateDelegate(":text, :password, :file, select, textarea", "focusin focusout keyup", delegate)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
379 .validateDelegate(":radio, :checkbox, select, option", "click", delegate);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
380
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
381 if (this.settings.invalidHandler)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
382 $(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
383 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
384
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
385 // http://docs.jquery.com/Plugins/Validation/Validator/form
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
386 form: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
387 /// <summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
388 /// Validates the form, returns true if it is valid, false otherwise.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
389 /// This behaves as a normal submit event, but returns the result.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
390 /// </summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
391 /// <returns type="Boolean" />
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
392
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
393 this.checkForm();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
394 $.extend(this.submitted, this.errorMap);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
395 this.invalid = $.extend({}, this.errorMap);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
396 if (!this.valid())
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
397 $(this.currentForm).triggerHandler("invalid-form", [this]);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
398 this.showErrors();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
399 return this.valid();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
400 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
401
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
402 checkForm: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
403 this.prepareForm();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
404 for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
405 this.check( elements[i] );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
406 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
407 return this.valid();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
408 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
409
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
410 // http://docs.jquery.com/Plugins/Validation/Validator/element
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
411 element: function( element ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
412 /// <summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
413 /// Validates a single element, returns true if it is valid, false otherwise.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
414 /// This behaves as validation on blur or keyup, but returns the result.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
415 /// </summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
416 /// <param name="element" type="Selector">
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
417 /// An element to validate, must be inside the validated form.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
418 /// </param>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
419 /// <returns type="Boolean" />
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
420
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
421 element = this.clean( element );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
422 this.lastElement = element;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
423 this.prepareElement( element );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
424 this.currentElements = $(element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
425 var result = this.check( element );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
426 if ( result ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
427 delete this.invalid[element.name];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
428 } else {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
429 this.invalid[element.name] = true;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
430 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
431 if ( !this.numberOfInvalids() ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
432 // Hide error containers on last error
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
433 this.toHide = this.toHide.add( this.containers );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
434 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
435 this.showErrors();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
436 return result;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
437 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
438
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
439 // http://docs.jquery.com/Plugins/Validation/Validator/showErrors
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
440 showErrors: function(errors) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
441 /// <summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
442 /// Show the specified messages.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
443 /// Keys have to refer to the names of elements, values are displayed for those elements, using the configured error placement.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
444 /// </summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
445 /// <param name="errors" type="Object">
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
446 /// One or more key/value pairs of input names and messages.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
447 /// </param>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
448 /// <returns type="undefined" />
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
449
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
450 if(errors) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
451 // add items to error list and map
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
452 $.extend( this.errorMap, errors );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
453 this.errorList = [];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
454 for ( var name in errors ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
455 this.errorList.push({
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
456 message: errors[name],
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
457 element: this.findByName(name)[0]
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
458 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
459 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
460 // remove items from success list
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
461 this.successList = $.grep( this.successList, function(element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
462 return !(element.name in errors);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
463 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
464 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
465 this.settings.showErrors
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
466 ? this.settings.showErrors.call( this, this.errorMap, this.errorList )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
467 : this.defaultShowErrors();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
468 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
469
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
470 // http://docs.jquery.com/Plugins/Validation/Validator/resetForm
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
471 resetForm: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
472 /// <summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
473 /// Resets the controlled form.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
474 /// Resets input fields to their original value (requires form plugin), removes classes
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
475 /// indicating invalid elements and hides error messages.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
476 /// </summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
477 /// <returns type="undefined" />
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
478
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
479 if ( $.fn.resetForm )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
480 $( this.currentForm ).resetForm();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
481 this.submitted = {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
482 this.prepareForm();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
483 this.hideErrors();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
484 this.elements().removeClass( this.settings.errorClass );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
485 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
486
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
487 numberOfInvalids: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
488 /// <summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
489 /// Returns the number of invalid fields.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
490 /// This depends on the internal validator state. It covers all fields only after
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
491 /// validating the complete form (on submit or via $("form").valid()). After validating
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
492 /// a single element, only that element is counted. Most useful in combination with the
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
493 /// invalidHandler-option.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
494 /// </summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
495 /// <returns type="Number" />
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
496
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
497 return this.objectLength(this.invalid);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
498 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
499
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
500 objectLength: function( obj ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
501 var count = 0;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
502 for ( var i in obj )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
503 count++;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
504 return count;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
505 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
506
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
507 hideErrors: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
508 this.addWrapper( this.toHide ).hide();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
509 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
510
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
511 valid: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
512 return this.size() == 0;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
513 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
514
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
515 size: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
516 return this.errorList.length;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
517 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
518
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
519 focusInvalid: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
520 if( this.settings.focusInvalid ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
521 try {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
522 $(this.findLastActive() || this.errorList.length && this.errorList[0].element || [])
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
523 .filter(":visible")
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
524 .focus()
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
525 // manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
526 .trigger("focusin");
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
527 } catch(e) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
528 // ignore IE throwing errors when focusing hidden elements
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
529 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
530 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
531 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
532
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
533 findLastActive: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
534 var lastActive = this.lastActive;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
535 return lastActive && $.grep(this.errorList, function(n) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
536 return n.element.name == lastActive.name;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
537 }).length == 1 && lastActive;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
538 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
539
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
540 elements: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
541 var validator = this,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
542 rulesCache = {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
543
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
544 // select all valid inputs inside the form (no submit or reset buttons)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
545 // workaround $Query([]).add until http://dev.jquery.com/ticket/2114 is solved
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
546 return $([]).add(this.currentForm.elements)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
547 .filter(":input")
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
548 .not(":submit, :reset, :image, [disabled]")
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
549 .not( this.settings.ignore )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
550 .filter(function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
551 !this.name && validator.settings.debug && window.console && console.error( "%o has no name assigned", this);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
552
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
553 // select only the first element for each name, and only those with rules specified
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
554 if ( this.name in rulesCache || !validator.objectLength($(this).rules()) )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
555 return false;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
556
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
557 rulesCache[this.name] = true;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
558 return true;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
559 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
560 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
561
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
562 clean: function( selector ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
563 return $( selector )[0];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
564 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
565
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
566 errors: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
567 return $( this.settings.errorElement + "." + this.settings.errorClass, this.errorContext );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
568 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
569
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
570 reset: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
571 this.successList = [];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
572 this.errorList = [];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
573 this.errorMap = {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
574 this.toShow = $([]);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
575 this.toHide = $([]);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
576 this.currentElements = $([]);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
577 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
578
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
579 prepareForm: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
580 this.reset();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
581 this.toHide = this.errors().add( this.containers );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
582 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
583
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
584 prepareElement: function( element ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
585 this.reset();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
586 this.toHide = this.errorsFor(element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
587 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
588
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
589 check: function( element ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
590 element = this.clean( element );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
591
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
592 // if radio/checkbox, validate first element in group instead
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
593 if (this.checkable(element)) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
594 element = this.findByName( element.name )[0];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
595 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
596
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
597 var rules = $(element).rules();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
598 var dependencyMismatch = false;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
599 for( method in rules ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
600 var rule = { method: method, parameters: rules[method] };
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
601 try {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
602 var result = $.validator.methods[method].call( this, element.value.replace(/\r/g, ""), element, rule.parameters );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
603
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
604 // if a method indicates that the field is optional and therefore valid,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
605 // don't mark it as valid when there are no other rules
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
606 if ( result == "dependency-mismatch" ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
607 dependencyMismatch = true;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
608 continue;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
609 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
610 dependencyMismatch = false;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
611
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
612 if ( result == "pending" ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
613 this.toHide = this.toHide.not( this.errorsFor(element) );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
614 return;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
615 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
616
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
617 if( !result ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
618 this.formatAndAdd( element, rule );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
619 return false;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
620 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
621 } catch(e) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
622 this.settings.debug && window.console && console.log("exception occured when checking element " + element.id
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
623 + ", check the '" + rule.method + "' method", e);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
624 throw e;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
625 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
626 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
627 if (dependencyMismatch)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
628 return;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
629 if ( this.objectLength(rules) )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
630 this.successList.push(element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
631 return true;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
632 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
633
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
634 // return the custom message for the given element and validation method
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
635 // specified in the element's "messages" metadata
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
636 customMetaMessage: function(element, method) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
637 if (!$.metadata)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
638 return;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
639
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
640 var meta = this.settings.meta
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
641 ? $(element).metadata()[this.settings.meta]
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
642 : $(element).metadata();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
643
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
644 return meta && meta.messages && meta.messages[method];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
645 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
646
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
647 // return the custom message for the given element name and validation method
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
648 customMessage: function( name, method ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
649 var m = this.settings.messages[name];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
650 return m && (m.constructor == String
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
651 ? m
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
652 : m[method]);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
653 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
654
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
655 // return the first defined argument, allowing empty strings
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
656 findDefined: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
657 for(var i = 0; i < arguments.length; i++) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
658 if (arguments[i] !== undefined)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
659 return arguments[i];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
660 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
661 return undefined;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
662 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
663
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
664 defaultMessage: function( element, method) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
665 return this.findDefined(
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
666 this.customMessage( element.name, method ),
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
667 this.customMetaMessage( element, method ),
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
668 // title is never undefined, so handle empty string as undefined
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
669 !this.settings.ignoreTitle && element.title || undefined,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
670 $.validator.messages[method],
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
671 "<strong>Warning: No message defined for " + element.name + "</strong>"
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
672 );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
673 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
674
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
675 formatAndAdd: function( element, rule ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
676 var message = this.defaultMessage( element, rule.method ),
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
677 theregex = /\$?\{(\d+)\}/g;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
678 if ( typeof message == "function" ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
679 message = message.call(this, rule.parameters, element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
680 } else if (theregex.test(message)) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
681 message = jQuery.format(message.replace(theregex, '{$1}'), rule.parameters);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
682 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
683 this.errorList.push({
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
684 message: message,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
685 element: element
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
686 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
687
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
688 this.errorMap[element.name] = message;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
689 this.submitted[element.name] = message;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
690 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
691
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
692 addWrapper: function(toToggle) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
693 if ( this.settings.wrapper )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
694 toToggle = toToggle.add( toToggle.parent( this.settings.wrapper ) );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
695 return toToggle;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
696 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
697
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
698 defaultShowErrors: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
699 for ( var i = 0; this.errorList[i]; i++ ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
700 var error = this.errorList[i];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
701 this.settings.highlight && this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
702 this.showLabel( error.element, error.message );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
703 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
704 if( this.errorList.length ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
705 this.toShow = this.toShow.add( this.containers );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
706 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
707 if (this.settings.success) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
708 for ( var i = 0; this.successList[i]; i++ ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
709 this.showLabel( this.successList[i] );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
710 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
711 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
712 if (this.settings.unhighlight) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
713 for ( var i = 0, elements = this.validElements(); elements[i]; i++ ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
714 this.settings.unhighlight.call( this, elements[i], this.settings.errorClass, this.settings.validClass );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
715 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
716 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
717 this.toHide = this.toHide.not( this.toShow );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
718 this.hideErrors();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
719 this.addWrapper( this.toShow ).show();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
720 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
721
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
722 validElements: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
723 return this.currentElements.not(this.invalidElements());
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
724 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
725
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
726 invalidElements: function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
727 return $(this.errorList).map(function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
728 return this.element;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
729 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
730 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
731
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
732 showLabel: function(element, message) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
733 var label = this.errorsFor( element );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
734 if ( label.length ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
735 // refresh error/success class
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
736 label.removeClass().addClass( this.settings.errorClass );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
737
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
738 // check if we have a generated label, replace the message then
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
739 label.attr("generated") && label.html(message);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
740 } else {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
741 // create label
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
742 label = $("<" + this.settings.errorElement + "/>")
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
743 .attr({"for": this.idOrName(element), generated: true})
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
744 .addClass(this.settings.errorClass)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
745 .html(message || "");
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
746 if ( this.settings.wrapper ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
747 // make sure the element is visible, even in IE
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
748 // actually showing the wrapped element is handled elsewhere
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
749 label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
750 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
751 if ( !this.labelContainer.append(label).length )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
752 this.settings.errorPlacement
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
753 ? this.settings.errorPlacement(label, $(element) )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
754 : label.insertAfter(element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
755 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
756 if ( !message && this.settings.success ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
757 label.text("");
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
758 typeof this.settings.success == "string"
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
759 ? label.addClass( this.settings.success )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
760 : this.settings.success( label );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
761 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
762 this.toShow = this.toShow.add(label);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
763 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
764
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
765 errorsFor: function(element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
766 var name = this.idOrName(element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
767 return this.errors().filter(function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
768 return $(this).attr('for') == name;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
769 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
770 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
771
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
772 idOrName: function(element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
773 return this.groups[element.name] || (this.checkable(element) ? element.name : element.id || element.name);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
774 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
775
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
776 checkable: function( element ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
777 return /radio|checkbox/i.test(element.type);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
778 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
779
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
780 findByName: function( name ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
781 // select by name and filter by form for performance over form.find("[name=...]")
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
782 var form = this.currentForm;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
783 return $(document.getElementsByName(name)).map(function(index, element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
784 return element.form == form && element.name == name && element || null;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
785 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
786 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
787
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
788 getLength: function(value, element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
789 switch( element.nodeName.toLowerCase() ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
790 case 'select':
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
791 return $("option:selected", element).length;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
792 case 'input':
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
793 if( this.checkable( element) )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
794 return this.findByName(element.name).filter(':checked').length;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
795 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
796 return value.length;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
797 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
798
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
799 depend: function(param, element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
800 return this.dependTypes[typeof param]
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
801 ? this.dependTypes[typeof param](param, element)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
802 : true;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
803 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
804
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
805 dependTypes: {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
806 "boolean": function(param, element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
807 return param;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
808 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
809 "string": function(param, element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
810 return !!$(param, element.form).length;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
811 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
812 "function": function(param, element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
813 return param(element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
814 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
815 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
816
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
817 optional: function(element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
818 return !$.validator.methods.required.call(this, $.trim(element.value), element) && "dependency-mismatch";
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
819 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
820
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
821 startRequest: function(element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
822 if (!this.pending[element.name]) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
823 this.pendingRequest++;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
824 this.pending[element.name] = true;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
825 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
826 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
827
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
828 stopRequest: function(element, valid) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
829 this.pendingRequest--;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
830 // sometimes synchronization fails, make sure pendingRequest is never < 0
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
831 if (this.pendingRequest < 0)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
832 this.pendingRequest = 0;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
833 delete this.pending[element.name];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
834 if ( valid && this.pendingRequest == 0 && this.formSubmitted && this.form() ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
835 $(this.currentForm).submit();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
836 this.formSubmitted = false;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
837 } else if (!valid && this.pendingRequest == 0 && this.formSubmitted) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
838 $(this.currentForm).triggerHandler("invalid-form", [this]);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
839 this.formSubmitted = false;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
840 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
841 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
842
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
843 previousValue: function(element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
844 return $.data(element, "previousValue") || $.data(element, "previousValue", {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
845 old: null,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
846 valid: true,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
847 message: this.defaultMessage( element, "remote" )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
848 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
849 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
850
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
851 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
852
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
853 classRuleSettings: {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
854 required: {required: true},
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
855 email: {email: true},
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
856 url: {url: true},
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
857 date: {date: true},
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
858 dateISO: {dateISO: true},
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
859 dateDE: {dateDE: true},
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
860 number: {number: true},
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
861 numberDE: {numberDE: true},
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
862 digits: {digits: true},
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
863 creditcard: {creditcard: true}
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
864 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
865
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
866 addClassRules: function(className, rules) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
867 /// <summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
868 /// Add a compound class method - useful to refactor common combinations of rules into a single
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
869 /// class.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
870 /// </summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
871 /// <param name="name" type="String">
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
872 /// The name of the class rule to add
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
873 /// </param>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
874 /// <param name="rules" type="Options">
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
875 /// The compound rules
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
876 /// </param>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
877 /// <returns type="undefined" />
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
878
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
879 className.constructor == String ?
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
880 this.classRuleSettings[className] = rules :
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
881 $.extend(this.classRuleSettings, className);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
882 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
883
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
884 classRules: function(element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
885 var rules = {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
886 var classes = $(element).attr('class');
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
887 classes && $.each(classes.split(' '), function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
888 if (this in $.validator.classRuleSettings) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
889 $.extend(rules, $.validator.classRuleSettings[this]);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
890 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
891 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
892 return rules;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
893 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
894
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
895 attributeRules: function(element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
896 var rules = {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
897 var $element = $(element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
898
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
899 for (method in $.validator.methods) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
900 var value = $element.attr(method);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
901 if (value) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
902 rules[method] = value;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
903 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
904 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
905
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
906 // maxlength may be returned as -1, 2147483647 (IE) and 524288 (safari) for text inputs
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
907 if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
908 delete rules.maxlength;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
909 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
910
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
911 return rules;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
912 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
913
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
914 metadataRules: function(element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
915 if (!$.metadata) return {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
916
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
917 var meta = $.data(element.form, 'validator').settings.meta;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
918 return meta ?
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
919 $(element).metadata()[meta] :
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
920 $(element).metadata();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
921 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
922
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
923 staticRules: function(element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
924 var rules = {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
925 var validator = $.data(element.form, 'validator');
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
926 if (validator.settings.rules) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
927 rules = $.validator.normalizeRule(validator.settings.rules[element.name]) || {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
928 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
929 return rules;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
930 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
931
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
932 normalizeRules: function(rules, element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
933 // handle dependency check
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
934 $.each(rules, function(prop, val) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
935 // ignore rule when param is explicitly false, eg. required:false
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
936 if (val === false) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
937 delete rules[prop];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
938 return;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
939 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
940 if (val.param || val.depends) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
941 var keepRule = true;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
942 switch (typeof val.depends) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
943 case "string":
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
944 keepRule = !!$(val.depends, element.form).length;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
945 break;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
946 case "function":
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
947 keepRule = val.depends.call(element, element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
948 break;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
949 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
950 if (keepRule) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
951 rules[prop] = val.param !== undefined ? val.param : true;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
952 } else {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
953 delete rules[prop];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
954 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
955 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
956 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
957
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
958 // evaluate parameters
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
959 $.each(rules, function(rule, parameter) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
960 rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
961 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
962
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
963 // clean number parameters
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
964 $.each(['minlength', 'maxlength', 'min', 'max'], function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
965 if (rules[this]) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
966 rules[this] = Number(rules[this]);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
967 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
968 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
969 $.each(['rangelength', 'range'], function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
970 if (rules[this]) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
971 rules[this] = [Number(rules[this][0]), Number(rules[this][1])];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
972 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
973 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
974
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
975 if ($.validator.autoCreateRanges) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
976 // auto-create ranges
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
977 if (rules.min && rules.max) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
978 rules.range = [rules.min, rules.max];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
979 delete rules.min;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
980 delete rules.max;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
981 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
982 if (rules.minlength && rules.maxlength) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
983 rules.rangelength = [rules.minlength, rules.maxlength];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
984 delete rules.minlength;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
985 delete rules.maxlength;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
986 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
987 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
988
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
989 // To support custom messages in metadata ignore rule methods titled "messages"
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
990 if (rules.messages) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
991 delete rules.messages;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
992 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
993
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
994 return rules;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
995 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
996
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
997 // Converts a simple string to a {string: true} rule, e.g., "required" to {required:true}
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
998 normalizeRule: function(data) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
999 if( typeof data == "string" ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1000 var transformed = {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1001 $.each(data.split(/\s/), function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1002 transformed[this] = true;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1003 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1004 data = transformed;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1005 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1006 return data;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1007 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1008
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1009 // http://docs.jquery.com/Plugins/Validation/Validator/addMethod
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1010 addMethod: function(name, method, message) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1011 /// <summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1012 /// Add a custom validation method. It must consist of a name (must be a legal javascript
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1013 /// identifier), a javascript based function and a default string message.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1014 /// </summary>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1015 /// <param name="name" type="String">
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1016 /// The name of the method, used to identify and referencing it, must be a valid javascript
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1017 /// identifier
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1018 /// </param>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1019 /// <param name="method" type="Function">
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1020 /// The actual method implementation, returning true if an element is valid
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1021 /// </param>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1022 /// <param name="message" type="String" optional="true">
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1023 /// (Optional) The default message to display for this method. Can be a function created by
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1024 /// jQuery.validator.format(value). When undefined, an already existing message is used
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1025 /// (handy for localization), otherwise the field-specific messages have to be defined.
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1026 /// </param>
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1027 /// <returns type="undefined" />
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1028
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1029 $.validator.methods[name] = method;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1030 $.validator.messages[name] = message != undefined ? message : $.validator.messages[name];
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1031 if (method.length < 3) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1032 $.validator.addClassRules(name, $.validator.normalizeRule(name));
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1033 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1034 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1035
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1036 methods: {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1037
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1038 // http://docs.jquery.com/Plugins/Validation/Methods/required
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1039 required: function(value, element, param) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1040 // check if dependency is met
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1041 if ( !this.depend(param, element) )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1042 return "dependency-mismatch";
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1043 switch( element.nodeName.toLowerCase() ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1044 case 'select':
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1045 // could be an array for select-multiple or a string, both are fine this way
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1046 var val = $(element).val();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1047 return val && val.length > 0;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1048 case 'input':
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1049 if ( this.checkable(element) )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1050 return this.getLength(value, element) > 0;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1051 default:
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1052 return $.trim(value).length > 0;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1053 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1054 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1055
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1056 // http://docs.jquery.com/Plugins/Validation/Methods/remote
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1057 remote: function(value, element, param) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1058 if ( this.optional(element) )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1059 return "dependency-mismatch";
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1060
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1061 var previous = this.previousValue(element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1062 if (!this.settings.messages[element.name] )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1063 this.settings.messages[element.name] = {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1064 previous.originalMessage = this.settings.messages[element.name].remote;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1065 this.settings.messages[element.name].remote = previous.message;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1066
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1067 param = typeof param == "string" && {url:param} || param;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1068
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1069 if ( previous.old !== value ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1070 previous.old = value;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1071 var validator = this;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1072 this.startRequest(element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1073 var data = {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1074 data[element.name] = value;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1075 $.ajax($.extend(true, {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1076 url: param,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1077 mode: "abort",
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1078 port: "validate" + element.name,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1079 dataType: "json",
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1080 data: data,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1081 success: function(response) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1082 validator.settings.messages[element.name].remote = previous.originalMessage;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1083 var valid = response === true;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1084 if ( valid ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1085 var submitted = validator.formSubmitted;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1086 validator.prepareElement(element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1087 validator.formSubmitted = submitted;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1088 validator.successList.push(element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1089 validator.showErrors();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1090 } else {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1091 var errors = {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1092 var message = (previous.message = response || validator.defaultMessage( element, "remote" ));
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1093 errors[element.name] = $.isFunction(message) ? message(value) : message;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1094 validator.showErrors(errors);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1095 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1096 previous.valid = valid;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1097 validator.stopRequest(element, valid);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1098 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1099 }, param));
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1100 return "pending";
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1101 } else if( this.pending[element.name] ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1102 return "pending";
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1103 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1104 return previous.valid;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1105 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1106
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1107 // http://docs.jquery.com/Plugins/Validation/Methods/minlength
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1108 minlength: function(value, element, param) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1109 return this.optional(element) || this.getLength($.trim(value), element) >= param;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1110 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1111
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1112 // http://docs.jquery.com/Plugins/Validation/Methods/maxlength
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1113 maxlength: function(value, element, param) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1114 return this.optional(element) || this.getLength($.trim(value), element) <= param;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1115 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1116
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1117 // http://docs.jquery.com/Plugins/Validation/Methods/rangelength
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1118 rangelength: function(value, element, param) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1119 var length = this.getLength($.trim(value), element);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1120 return this.optional(element) || ( length >= param[0] && length <= param[1] );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1121 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1122
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1123 // http://docs.jquery.com/Plugins/Validation/Methods/min
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1124 min: function( value, element, param ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1125 return this.optional(element) || value >= param;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1126 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1127
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1128 // http://docs.jquery.com/Plugins/Validation/Methods/max
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1129 max: function( value, element, param ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1130 return this.optional(element) || value <= param;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1131 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1132
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1133 // http://docs.jquery.com/Plugins/Validation/Methods/range
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1134 range: function( value, element, param ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1135 return this.optional(element) || ( value >= param[0] && value <= param[1] );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1136 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1137
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1138 // http://docs.jquery.com/Plugins/Validation/Methods/email
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1139 email: function(value, element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1140 // contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1141 return this.optional(element) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([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])))\.?$/i.test(value);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1142 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1143
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1144 // http://docs.jquery.com/Plugins/Validation/Methods/url
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1145 url: function(value, element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1146 // contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1147 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);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1148 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1149
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1150 // http://docs.jquery.com/Plugins/Validation/Methods/date
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1151 date: function(value, element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1152 return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1153 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1154
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1155 // http://docs.jquery.com/Plugins/Validation/Methods/dateISO
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1156 dateISO: function(value, element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1157 return this.optional(element) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1158 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1159
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1160 // http://docs.jquery.com/Plugins/Validation/Methods/number
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1161 number: function(value, element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1162 return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1163 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1164
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1165 // http://docs.jquery.com/Plugins/Validation/Methods/digits
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1166 digits: function(value, element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1167 return this.optional(element) || /^\d+$/.test(value);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1168 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1169
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1170 // http://docs.jquery.com/Plugins/Validation/Methods/creditcard
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1171 // based on http://en.wikipedia.org/wiki/Luhn
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1172 creditcard: function(value, element) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1173 if ( this.optional(element) )
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1174 return "dependency-mismatch";
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1175 // accept only digits and dashes
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1176 if (/[^0-9-]+/.test(value))
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1177 return false;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1178 var nCheck = 0,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1179 nDigit = 0,
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1180 bEven = false;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1181
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1182 value = value.replace(/\D/g, "");
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1183
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1184 for (var n = value.length - 1; n >= 0; n--) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1185 var cDigit = value.charAt(n);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1186 var nDigit = parseInt(cDigit, 10);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1187 if (bEven) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1188 if ((nDigit *= 2) > 9)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1189 nDigit -= 9;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1190 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1191 nCheck += nDigit;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1192 bEven = !bEven;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1193 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1194
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1195 return (nCheck % 10) == 0;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1196 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1197
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1198 // http://docs.jquery.com/Plugins/Validation/Methods/accept
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1199 accept: function(value, element, param) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1200 param = typeof param == "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif";
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1201 return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1202 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1203
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1204 // http://docs.jquery.com/Plugins/Validation/Methods/equalTo
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1205 equalTo: function(value, element, param) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1206 // bind to the blur event of the target in order to revalidate whenever the target field is updated
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1207 // TODO find a way to bind the event just once, avoiding the unbind-rebind overhead
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1208 var target = $(param).unbind(".validate-equalTo").bind("blur.validate-equalTo", function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1209 $(element).valid();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1210 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1211 return value == target.val();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1212 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1213
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1214 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1215
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1216 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1217
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1218 // deprecated, use $.validator.format instead
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1219 $.format = $.validator.format;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1220
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1221 })(jQuery);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1222
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1223 // ajax mode: abort
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1224 // usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1225 // if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1226 ;(function($) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1227 var ajax = $.ajax;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1228 var pendingRequests = {};
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1229 $.ajax = function(settings) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1230 // create settings for compatibility with ajaxSetup
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1231 settings = $.extend(settings, $.extend({}, $.ajaxSettings, settings));
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1232 var port = settings.port;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1233 if (settings.mode == "abort") {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1234 if ( pendingRequests[port] ) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1235 pendingRequests[port].abort();
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1236 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1237 return (pendingRequests[port] = ajax.apply(this, arguments));
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1238 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1239 return ajax.apply(this, arguments);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1240 };
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1241 })(jQuery);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1242
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1243 // provides cross-browser focusin and focusout events
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1244 // IE has native support, in other browsers, use event caputuring (neither bubbles)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1245
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1246 // provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1247 // handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1248 ;(function($) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1249 // only implement if not provided by jQuery core (since 1.4)
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1250 // TODO verify if jQuery 1.4's implementation is compatible with older jQuery special-event APIs
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1251 if (!jQuery.event.special.focusin && !jQuery.event.special.focusout && document.addEventListener) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1252 $.each({
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1253 focus: 'focusin',
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1254 blur: 'focusout'
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1255 }, function( original, fix ){
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1256 $.event.special[fix] = {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1257 setup:function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1258 this.addEventListener( original, handler, true );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1259 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1260 teardown:function() {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1261 this.removeEventListener( original, handler, true );
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1262 },
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1263 handler: function(e) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1264 arguments[0] = $.event.fix(e);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1265 arguments[0].type = fix;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1266 return $.event.handle.apply(this, arguments);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1267 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1268 };
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1269 function handler(e) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1270 e = $.event.fix(e);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1271 e.type = fix;
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1272 return $.event.handle.call(this, e);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1273 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1274 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1275 };
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1276 $.extend($.fn, {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1277 validateDelegate: function(delegate, type, handler) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1278 return this.bind(type, function(event) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1279 var target = $(event.target);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1280 if (target.is(delegate)) {
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1281 return handler.apply(target, arguments);
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1282 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1283 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1284 }
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1285 });
c62b77fc33f4 website inicial
nelo@MTEySS.neluz.int
parents:
diff changeset
1286 })(jQuery);