jekyll-agency 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/404.html +6 -2
- data/LICENSE.txt +21 -21
- data/README.md +184 -116
- data/_data/navigation.yml +58 -18
- data/_data/sitetext.yml +322 -139
- data/_data/style.yml +10 -11
- data/_includes/about.html +16 -16
- data/_includes/clients.html +5 -5
- data/_includes/contact.html +54 -40
- data/_includes/footer.html +50 -31
- data/_includes/head.html +20 -15
- data/_includes/modals.html +37 -21
- data/_includes/nav.html +46 -29
- data/_includes/navheader.html +16 -17
- data/_includes/portfolio_grid.html +3 -3
- data/_includes/services.html +5 -5
- data/_includes/team.html +5 -5
- data/_includes/timeline.html +26 -13
- data/_layouts/default.html +26 -26
- data/_layouts/home.html +12 -11
- data/_layouts/page.html +14 -8
- data/_sass/base/_mixins.scss +12 -4
- data/_sass/base/_page.scss +1 -1
- data/_sass/components/_buttons.scss +1 -1
- data/_sass/components/_navbar.scss +1 -1
- data/_sass/components/client-scroll.scss +11 -11
- data/_sass/layout/_masthead.scss +1 -1
- data/_sass/layout/_portfolio.scss +2 -2
- data/_sass/layout/_timeline.scss +6 -6
- data/assets/css/all.min.css +4 -4
- data/assets/css/webfonts/fa-brands-400.svg +3449 -3449
- data/assets/css/webfonts/fa-regular-400.svg +803 -803
- data/assets/css/webfonts/fa-solid-900.svg +4649 -4649
- data/assets/js/contact_me.js +5 -4
- data/assets/js/jqBootstrapValidation.js +470 -314
- data/index.md +1 -1
- data/legal.md +39 -37
- metadata +5 -5
@@ -8,8 +8,7 @@
|
|
8
8
|
* http://ReactiveRaven.github.com/jqBootstrapValidation/
|
9
9
|
*/
|
10
10
|
|
11
|
-
(function($) {
|
12
|
-
|
11
|
+
(function ($) {
|
13
12
|
var createdElements = [];
|
14
13
|
|
15
14
|
var defaults = {
|
@@ -21,16 +20,15 @@
|
|
21
20
|
submitSuccess: false, // function called just before a successful submit event is sent to the server
|
22
21
|
semanticallyStrict: false, // set to true to tidy up generated HTML output
|
23
22
|
autoAdd: {
|
24
|
-
helpBlocks: true
|
23
|
+
helpBlocks: true,
|
25
24
|
},
|
26
|
-
filter: function() {
|
25
|
+
filter: function () {
|
27
26
|
// return $(this).is(":visible"); // only validate elements you can see
|
28
27
|
return true; // validate everything
|
29
|
-
}
|
28
|
+
},
|
30
29
|
},
|
31
30
|
methods: {
|
32
|
-
init: function(options) {
|
33
|
-
|
31
|
+
init: function (options) {
|
34
32
|
var settings = $.extend(true, {}, defaults);
|
35
33
|
|
36
34
|
settings.options = $.extend(true, settings.options, options);
|
@@ -38,23 +36,28 @@
|
|
38
36
|
var $siblingElements = this;
|
39
37
|
|
40
38
|
var uniqueForms = $.unique(
|
41
|
-
$siblingElements
|
42
|
-
|
43
|
-
|
39
|
+
$siblingElements
|
40
|
+
.map(function () {
|
41
|
+
return $(this).parents("form")[0];
|
42
|
+
})
|
43
|
+
.toArray()
|
44
44
|
);
|
45
45
|
|
46
|
-
$(uniqueForms).bind("submit", function(e) {
|
46
|
+
$(uniqueForms).bind("submit", function (e) {
|
47
47
|
var $form = $(this);
|
48
48
|
var warningsFound = 0;
|
49
|
-
var $inputs = $form
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
var $inputs = $form
|
50
|
+
.find("input,textarea,select")
|
51
|
+
.not("[type=submit],[type=image]")
|
52
|
+
.filter(settings.options.filter);
|
53
|
+
$inputs
|
54
|
+
.trigger("submit.validation")
|
55
|
+
.trigger("validationLostFocus.validation");
|
56
|
+
|
57
|
+
$inputs.each(function (i, el) {
|
53
58
|
var $this = $(el),
|
54
59
|
$controlGroup = $this.parents(".form-group").first();
|
55
|
-
if (
|
56
|
-
$controlGroup.hasClass("warning")
|
57
|
-
) {
|
60
|
+
if ($controlGroup.hasClass("warning")) {
|
58
61
|
$controlGroup.removeClass("warning").addClass("error");
|
59
62
|
warningsFound++;
|
60
63
|
}
|
@@ -68,7 +71,11 @@
|
|
68
71
|
}
|
69
72
|
$form.addClass("error");
|
70
73
|
if ($.isFunction(settings.options.submitError)) {
|
71
|
-
settings.options.submitError(
|
74
|
+
settings.options.submitError(
|
75
|
+
$form,
|
76
|
+
e,
|
77
|
+
$inputs.jqBootstrapValidation("collectErrors", true)
|
78
|
+
);
|
72
79
|
}
|
73
80
|
} else {
|
74
81
|
$form.removeClass("error");
|
@@ -78,8 +85,7 @@
|
|
78
85
|
}
|
79
86
|
});
|
80
87
|
|
81
|
-
return this.each(function() {
|
82
|
-
|
88
|
+
return this.each(function () {
|
83
89
|
// Get references to everything we're interested in
|
84
90
|
var $this = $(this),
|
85
91
|
$controlGroup = $this.parents(".form-group").first(),
|
@@ -88,9 +94,13 @@
|
|
88
94
|
validatorNames = [];
|
89
95
|
|
90
96
|
// create message container if not exists
|
91
|
-
if (
|
97
|
+
if (
|
98
|
+
!$helpBlock.length &&
|
99
|
+
settings.options.autoAdd &&
|
100
|
+
settings.options.autoAdd.helpBlocks
|
101
|
+
) {
|
92
102
|
$helpBlock = $('<div class="help-block" />');
|
93
|
-
$controlGroup.find(
|
103
|
+
$controlGroup.find(".controls").append($helpBlock);
|
94
104
|
createdElements.push($helpBlock[0]);
|
95
105
|
}
|
96
106
|
|
@@ -106,7 +116,8 @@
|
|
106
116
|
// PATTERN
|
107
117
|
// ---------------------------------------------------------
|
108
118
|
if ($this.attr("pattern") !== undefined) {
|
109
|
-
message =
|
119
|
+
message =
|
120
|
+
"Not in the expected format<!-- data-validation-pattern-message to override -->";
|
110
121
|
if ($this.data("validationPatternMessage")) {
|
111
122
|
message = $this.data("validationPatternMessage");
|
112
123
|
}
|
@@ -116,9 +127,18 @@
|
|
116
127
|
// ---------------------------------------------------------
|
117
128
|
// MAX
|
118
129
|
// ---------------------------------------------------------
|
119
|
-
if (
|
120
|
-
|
121
|
-
|
130
|
+
if (
|
131
|
+
$this.attr("max") !== undefined ||
|
132
|
+
$this.attr("aria-valuemax") !== undefined
|
133
|
+
) {
|
134
|
+
var max =
|
135
|
+
$this.attr("max") !== undefined
|
136
|
+
? $this.attr("max")
|
137
|
+
: $this.attr("aria-valuemax");
|
138
|
+
message =
|
139
|
+
"Too high: Maximum of '" +
|
140
|
+
max +
|
141
|
+
"'<!-- data-validation-max-message to override -->";
|
122
142
|
if ($this.data("validationMaxMessage")) {
|
123
143
|
message = $this.data("validationMaxMessage");
|
124
144
|
}
|
@@ -128,9 +148,18 @@
|
|
128
148
|
// ---------------------------------------------------------
|
129
149
|
// MIN
|
130
150
|
// ---------------------------------------------------------
|
131
|
-
if (
|
132
|
-
|
133
|
-
|
151
|
+
if (
|
152
|
+
$this.attr("min") !== undefined ||
|
153
|
+
$this.attr("aria-valuemin") !== undefined
|
154
|
+
) {
|
155
|
+
var min =
|
156
|
+
$this.attr("min") !== undefined
|
157
|
+
? $this.attr("min")
|
158
|
+
: $this.attr("aria-valuemin");
|
159
|
+
message =
|
160
|
+
"Too low: Minimum of '" +
|
161
|
+
min +
|
162
|
+
"'<!-- data-validation-min-message to override -->";
|
134
163
|
if ($this.data("validationMinMessage")) {
|
135
164
|
message = $this.data("validationMinMessage");
|
136
165
|
}
|
@@ -141,28 +170,43 @@
|
|
141
170
|
// MAXLENGTH
|
142
171
|
// ---------------------------------------------------------
|
143
172
|
if ($this.attr("maxlength") !== undefined) {
|
144
|
-
message =
|
173
|
+
message =
|
174
|
+
"Too long: Maximum of '" +
|
175
|
+
$this.attr("maxlength") +
|
176
|
+
"' characters<!-- data-validation-maxlength-message to override -->";
|
145
177
|
if ($this.data("validationMaxlengthMessage")) {
|
146
178
|
message = $this.data("validationMaxlengthMessage");
|
147
179
|
}
|
148
180
|
$this.data("validationMaxlengthMessage", message);
|
149
|
-
$this.data(
|
181
|
+
$this.data(
|
182
|
+
"validationMaxlengthMaxlength",
|
183
|
+
$this.attr("maxlength")
|
184
|
+
);
|
150
185
|
}
|
151
186
|
// ---------------------------------------------------------
|
152
187
|
// MINLENGTH
|
153
188
|
// ---------------------------------------------------------
|
154
189
|
if ($this.attr("minlength") !== undefined) {
|
155
|
-
message =
|
190
|
+
message =
|
191
|
+
"Too short: Minimum of '" +
|
192
|
+
$this.attr("minlength") +
|
193
|
+
"' characters<!-- data-validation-minlength-message to override -->";
|
156
194
|
if ($this.data("validationMinlengthMessage")) {
|
157
195
|
message = $this.data("validationMinlengthMessage");
|
158
196
|
}
|
159
197
|
$this.data("validationMinlengthMessage", message);
|
160
|
-
$this.data(
|
198
|
+
$this.data(
|
199
|
+
"validationMinlengthMinlength",
|
200
|
+
$this.attr("minlength")
|
201
|
+
);
|
161
202
|
}
|
162
203
|
// ---------------------------------------------------------
|
163
204
|
// REQUIRED
|
164
205
|
// ---------------------------------------------------------
|
165
|
-
if (
|
206
|
+
if (
|
207
|
+
$this.attr("required") !== undefined ||
|
208
|
+
$this.attr("aria-required") !== undefined
|
209
|
+
) {
|
166
210
|
message = settings.builtInValidators.required.message;
|
167
211
|
if ($this.data("validationRequiredMessage")) {
|
168
212
|
message = $this.data("validationRequiredMessage");
|
@@ -172,7 +216,10 @@
|
|
172
216
|
// ---------------------------------------------------------
|
173
217
|
// NUMBER
|
174
218
|
// ---------------------------------------------------------
|
175
|
-
if (
|
219
|
+
if (
|
220
|
+
$this.attr("type") !== undefined &&
|
221
|
+
$this.attr("type").toLowerCase() === "number"
|
222
|
+
) {
|
176
223
|
message = settings.builtInValidators.number.message;
|
177
224
|
if ($this.data("validationNumberMessage")) {
|
178
225
|
message = $this.data("validationNumberMessage");
|
@@ -182,8 +229,12 @@
|
|
182
229
|
// ---------------------------------------------------------
|
183
230
|
// EMAIL
|
184
231
|
// ---------------------------------------------------------
|
185
|
-
if (
|
186
|
-
|
232
|
+
if (
|
233
|
+
$this.attr("type") !== undefined &&
|
234
|
+
$this.attr("type").toLowerCase() === "email"
|
235
|
+
) {
|
236
|
+
message =
|
237
|
+
"Not a valid email address<!-- data-validator-validemail-message to override -->";
|
187
238
|
if ($this.data("validationValidemailMessage")) {
|
188
239
|
message = $this.data("validationValidemailMessage");
|
189
240
|
} else if ($this.data("validationEmailMessage")) {
|
@@ -195,23 +246,35 @@
|
|
195
246
|
// MINCHECKED
|
196
247
|
// ---------------------------------------------------------
|
197
248
|
if ($this.attr("minchecked") !== undefined) {
|
198
|
-
message =
|
249
|
+
message =
|
250
|
+
"Not enough options checked; Minimum of '" +
|
251
|
+
$this.attr("minchecked") +
|
252
|
+
"' required<!-- data-validation-minchecked-message to override -->";
|
199
253
|
if ($this.data("validationMincheckedMessage")) {
|
200
254
|
message = $this.data("validationMincheckedMessage");
|
201
255
|
}
|
202
256
|
$this.data("validationMincheckedMessage", message);
|
203
|
-
$this.data(
|
257
|
+
$this.data(
|
258
|
+
"validationMincheckedMinchecked",
|
259
|
+
$this.attr("minchecked")
|
260
|
+
);
|
204
261
|
}
|
205
262
|
// ---------------------------------------------------------
|
206
263
|
// MAXCHECKED
|
207
264
|
// ---------------------------------------------------------
|
208
265
|
if ($this.attr("maxchecked") !== undefined) {
|
209
|
-
message =
|
266
|
+
message =
|
267
|
+
"Too many options checked; Maximum of '" +
|
268
|
+
$this.attr("maxchecked") +
|
269
|
+
"' required<!-- data-validation-maxchecked-message to override -->";
|
210
270
|
if ($this.data("validationMaxcheckedMessage")) {
|
211
271
|
message = $this.data("validationMaxcheckedMessage");
|
212
272
|
}
|
213
273
|
$this.data("validationMaxcheckedMessage", message);
|
214
|
-
$this.data(
|
274
|
+
$this.data(
|
275
|
+
"validationMaxcheckedMaxchecked",
|
276
|
+
$this.attr("maxchecked")
|
277
|
+
);
|
215
278
|
}
|
216
279
|
}
|
217
280
|
|
@@ -225,7 +288,7 @@
|
|
225
288
|
}
|
226
289
|
|
227
290
|
// Get extra ones defined on the element's data attributes
|
228
|
-
$.each($this.data(), function(i, el) {
|
291
|
+
$.each($this.data(), function (i, el) {
|
229
292
|
var parts = i.replace(/([A-Z])/g, ",$1").split(",");
|
230
293
|
if (parts[0] === "validation" && parts[1]) {
|
231
294
|
validatorNames.push(parts[1]);
|
@@ -242,7 +305,7 @@
|
|
242
305
|
do // repeatedly expand 'shortcut' validators into their real validators
|
243
306
|
{
|
244
307
|
// Uppercase only the first letter of each name
|
245
|
-
$.each(validatorNames, function(i, el) {
|
308
|
+
$.each(validatorNames, function (i, el) {
|
246
309
|
validatorNames[i] = formatValidatorName(el);
|
247
310
|
});
|
248
311
|
|
@@ -251,19 +314,22 @@
|
|
251
314
|
|
252
315
|
// Pull out the new validator names from each shortcut
|
253
316
|
newValidatorNamesToInspect = [];
|
254
|
-
$.each(validatorNamesToInspect, function(i, el) {
|
317
|
+
$.each(validatorNamesToInspect, function (i, el) {
|
255
318
|
if ($this.data("validation" + el + "Shortcut") !== undefined) {
|
256
319
|
// Are these custom validators?
|
257
320
|
// Pull them out!
|
258
|
-
$.each(
|
259
|
-
|
260
|
-
|
321
|
+
$.each(
|
322
|
+
$this.data("validation" + el + "Shortcut").split(","),
|
323
|
+
function (i2, el2) {
|
324
|
+
newValidatorNamesToInspect.push(el2);
|
325
|
+
}
|
326
|
+
);
|
261
327
|
} else if (settings.builtInValidators[el.toLowerCase()]) {
|
262
328
|
// Is this a recognised built-in?
|
263
329
|
// Pull it out!
|
264
330
|
var validator = settings.builtInValidators[el.toLowerCase()];
|
265
331
|
if (validator.type.toLowerCase() === "shortcut") {
|
266
|
-
$.each(validator.shortcut.split(","), function(i, el) {
|
332
|
+
$.each(validator.shortcut.split(","), function (i, el) {
|
267
333
|
el = formatValidatorName(el);
|
268
334
|
newValidatorNamesToInspect.push(el);
|
269
335
|
validatorNames.push(el);
|
@@ -273,8 +339,7 @@
|
|
273
339
|
});
|
274
340
|
|
275
341
|
validatorNamesToInspect = newValidatorNamesToInspect;
|
276
|
-
|
277
|
-
} while (validatorNamesToInspect.length > 0)
|
342
|
+
} while (validatorNamesToInspect.length > 0);
|
278
343
|
|
279
344
|
// =============================================================
|
280
345
|
// SET UP VALIDATOR ARRAYS
|
@@ -282,30 +347,39 @@
|
|
282
347
|
|
283
348
|
var validators = {};
|
284
349
|
|
285
|
-
$.each(validatorNames, function(i, el) {
|
350
|
+
$.each(validatorNames, function (i, el) {
|
286
351
|
// Set up the 'override' message
|
287
352
|
var message = $this.data("validation" + el + "Message");
|
288
|
-
var hasOverrideMessage =
|
353
|
+
var hasOverrideMessage = message !== undefined;
|
289
354
|
var foundValidator = false;
|
290
|
-
message =
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
"'
|
295
|
-
|
355
|
+
message = message
|
356
|
+
? message
|
357
|
+
: "'" +
|
358
|
+
el +
|
359
|
+
"' validation failed <!-- Add attribute 'data-validation-" +
|
360
|
+
el.toLowerCase() +
|
361
|
+
"-message' to input to change this message -->";
|
296
362
|
|
297
363
|
$.each(
|
298
364
|
settings.validatorTypes,
|
299
|
-
function(validatorType, validatorTemplate) {
|
365
|
+
function (validatorType, validatorTemplate) {
|
300
366
|
if (validators[validatorType] === undefined) {
|
301
367
|
validators[validatorType] = [];
|
302
368
|
}
|
303
|
-
if (
|
369
|
+
if (
|
370
|
+
!foundValidator &&
|
371
|
+
$this.data(
|
372
|
+
"validation" +
|
373
|
+
el +
|
374
|
+
formatValidatorName(validatorTemplate.name)
|
375
|
+
) !== undefined
|
376
|
+
) {
|
304
377
|
validators[validatorType].push(
|
305
378
|
$.extend(
|
306
|
-
true,
|
379
|
+
true,
|
380
|
+
{
|
307
381
|
name: formatValidatorName(validatorTemplate.name),
|
308
|
-
message: message
|
382
|
+
message: message,
|
309
383
|
},
|
310
384
|
validatorTemplate.init($this, el)
|
311
385
|
)
|
@@ -315,9 +389,15 @@
|
|
315
389
|
}
|
316
390
|
);
|
317
391
|
|
318
|
-
if (
|
319
|
-
|
320
|
-
|
392
|
+
if (
|
393
|
+
!foundValidator &&
|
394
|
+
settings.builtInValidators[el.toLowerCase()]
|
395
|
+
) {
|
396
|
+
var validator = $.extend(
|
397
|
+
true,
|
398
|
+
{},
|
399
|
+
settings.builtInValidators[el.toLowerCase()]
|
400
|
+
);
|
321
401
|
if (hasOverrideMessage) {
|
322
402
|
validator.message = message;
|
323
403
|
}
|
@@ -328,17 +408,22 @@
|
|
328
408
|
} else {
|
329
409
|
$.each(
|
330
410
|
settings.validatorTypes,
|
331
|
-
function(validatorTemplateType, validatorTemplate) {
|
411
|
+
function (validatorTemplateType, validatorTemplate) {
|
332
412
|
if (validators[validatorTemplateType] === undefined) {
|
333
413
|
validators[validatorTemplateType] = [];
|
334
414
|
}
|
335
|
-
if (
|
336
|
-
|
415
|
+
if (
|
416
|
+
!foundValidator &&
|
417
|
+
validatorType === validatorTemplateType.toLowerCase()
|
418
|
+
) {
|
419
|
+
$this.data(
|
420
|
+
"validation" +
|
421
|
+
el +
|
422
|
+
formatValidatorName(validatorTemplate.name),
|
423
|
+
validator[validatorTemplate.name.toLowerCase()]
|
424
|
+
);
|
337
425
|
validators[validatorType].push(
|
338
|
-
$.extend(
|
339
|
-
validator,
|
340
|
-
validatorTemplate.init($this, el)
|
341
|
-
)
|
426
|
+
$.extend(validator, validatorTemplate.init($this, el))
|
342
427
|
);
|
343
428
|
foundValidator = true;
|
344
429
|
}
|
@@ -358,85 +443,80 @@
|
|
358
443
|
|
359
444
|
$helpBlock.data(
|
360
445
|
"original-contents",
|
361
|
-
(
|
362
|
-
$helpBlock.data("original-contents")
|
363
|
-
$helpBlock.
|
364
|
-
$helpBlock.html()
|
365
|
-
)
|
446
|
+
$helpBlock.data("original-contents")
|
447
|
+
? $helpBlock.data("original-contents")
|
448
|
+
: $helpBlock.html()
|
366
449
|
);
|
367
450
|
|
368
451
|
$helpBlock.data(
|
369
452
|
"original-role",
|
370
|
-
(
|
371
|
-
$helpBlock.data("original-role")
|
372
|
-
$helpBlock.
|
373
|
-
$helpBlock.attr("role")
|
374
|
-
)
|
453
|
+
$helpBlock.data("original-role")
|
454
|
+
? $helpBlock.data("original-role")
|
455
|
+
: $helpBlock.attr("role")
|
375
456
|
);
|
376
457
|
|
377
458
|
$controlGroup.data(
|
378
459
|
"original-classes",
|
379
|
-
(
|
380
|
-
$controlGroup.data("original-
|
381
|
-
$controlGroup.
|
382
|
-
$controlGroup.attr("class")
|
383
|
-
)
|
460
|
+
$controlGroup.data("original-clases")
|
461
|
+
? $controlGroup.data("original-classes")
|
462
|
+
: $controlGroup.attr("class")
|
384
463
|
);
|
385
464
|
|
386
465
|
$this.data(
|
387
466
|
"original-aria-invalid",
|
388
|
-
(
|
389
|
-
$this.data("original-aria-invalid")
|
390
|
-
$this.
|
391
|
-
$this.attr("aria-invalid")
|
392
|
-
)
|
467
|
+
$this.data("original-aria-invalid")
|
468
|
+
? $this.data("original-aria-invalid")
|
469
|
+
: $this.attr("aria-invalid")
|
393
470
|
);
|
394
471
|
|
395
472
|
// =============================================================
|
396
473
|
// VALIDATION
|
397
474
|
// =============================================================
|
398
475
|
|
399
|
-
$this.bind(
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
476
|
+
$this.bind("validation.validation", function (event, params) {
|
477
|
+
var value = getValue($this);
|
478
|
+
|
479
|
+
// Get a list of the errors to apply
|
480
|
+
var errorsFound = [];
|
481
|
+
|
482
|
+
$.each(validators, function (validatorType, validatorTypeArray) {
|
483
|
+
if (
|
484
|
+
value ||
|
485
|
+
value.length ||
|
486
|
+
(params && params.includeEmpty) ||
|
487
|
+
(!!settings.validatorTypes[validatorType].blockSubmit &&
|
488
|
+
params &&
|
489
|
+
!!params.submitting)
|
490
|
+
) {
|
491
|
+
$.each(validatorTypeArray, function (i, validator) {
|
492
|
+
if (
|
493
|
+
settings.validatorTypes[validatorType].validate(
|
494
|
+
$this,
|
495
|
+
value,
|
496
|
+
validator
|
497
|
+
)
|
498
|
+
) {
|
499
|
+
errorsFound.push(validator.message);
|
500
|
+
}
|
501
|
+
});
|
502
|
+
}
|
503
|
+
});
|
417
504
|
|
418
|
-
|
419
|
-
|
420
|
-
);
|
505
|
+
return errorsFound;
|
506
|
+
});
|
421
507
|
|
422
|
-
$this.bind(
|
423
|
-
|
424
|
-
|
425
|
-
return validators;
|
426
|
-
}
|
427
|
-
);
|
508
|
+
$this.bind("getValidators.validation", function () {
|
509
|
+
return validators;
|
510
|
+
});
|
428
511
|
|
429
512
|
// =============================================================
|
430
513
|
// WATCH FOR CHANGES
|
431
514
|
// =============================================================
|
432
|
-
$this.bind(
|
433
|
-
"
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
});
|
438
|
-
}
|
439
|
-
);
|
515
|
+
$this.bind("submit.validation", function () {
|
516
|
+
return $this.triggerHandler("change.validation", {
|
517
|
+
submitting: true,
|
518
|
+
});
|
519
|
+
});
|
440
520
|
$this.bind(
|
441
521
|
[
|
442
522
|
"keyup",
|
@@ -445,28 +525,39 @@
|
|
445
525
|
"click",
|
446
526
|
"keydown",
|
447
527
|
"keypress",
|
448
|
-
"change"
|
528
|
+
"change",
|
449
529
|
].join(".validation ") + ".validation",
|
450
|
-
function(e, params) {
|
451
|
-
|
530
|
+
function (e, params) {
|
452
531
|
var value = getValue($this);
|
453
532
|
|
454
533
|
var errorsFound = [];
|
455
534
|
|
456
|
-
$controlGroup
|
457
|
-
|
458
|
-
|
459
|
-
errorsFound.
|
535
|
+
$controlGroup
|
536
|
+
.find("input,textarea,select")
|
537
|
+
.each(function (i, el) {
|
538
|
+
var oldCount = errorsFound.length;
|
539
|
+
$.each(
|
540
|
+
$(el).triggerHandler("validation.validation", params),
|
541
|
+
function (j, message) {
|
542
|
+
errorsFound.push(message);
|
543
|
+
}
|
544
|
+
);
|
545
|
+
if (errorsFound.length > oldCount) {
|
546
|
+
$(el).attr("aria-invalid", "true");
|
547
|
+
} else {
|
548
|
+
var original = $this.data("original-aria-invalid");
|
549
|
+
$(el).attr(
|
550
|
+
"aria-invalid",
|
551
|
+
original !== undefined ? original : false
|
552
|
+
);
|
553
|
+
}
|
460
554
|
});
|
461
|
-
if (errorsFound.length > oldCount) {
|
462
|
-
$(el).attr("aria-invalid", "true");
|
463
|
-
} else {
|
464
|
-
var original = $this.data("original-aria-invalid");
|
465
|
-
$(el).attr("aria-invalid", (original !== undefined ? original : false));
|
466
|
-
}
|
467
|
-
});
|
468
555
|
|
469
|
-
$form
|
556
|
+
$form
|
557
|
+
.find("input,select,textarea")
|
558
|
+
.not($this)
|
559
|
+
.not('[name="' + $this.attr("name") + '"]')
|
560
|
+
.trigger("validationLostFocus.validation");
|
470
561
|
|
471
562
|
errorsFound = $.unique(errorsFound.sort());
|
472
563
|
|
@@ -476,14 +567,27 @@
|
|
476
567
|
$controlGroup.removeClass("success error").addClass("warning");
|
477
568
|
|
478
569
|
// How many errors did we find?
|
479
|
-
if (
|
570
|
+
if (
|
571
|
+
settings.options.semanticallyStrict &&
|
572
|
+
errorsFound.length === 1
|
573
|
+
) {
|
480
574
|
// Only one? Being strict? Just output it.
|
481
|
-
$helpBlock.html(
|
482
|
-
|
575
|
+
$helpBlock.html(
|
576
|
+
errorsFound[0] +
|
577
|
+
(settings.options.prependExistingHelpBlock
|
578
|
+
? $helpBlock.data("original-contents")
|
579
|
+
: "")
|
580
|
+
);
|
483
581
|
} else {
|
484
582
|
// Multiple? Being sloppy? Glue them together into an UL.
|
485
|
-
$helpBlock.html(
|
486
|
-
|
583
|
+
$helpBlock.html(
|
584
|
+
'<ul role="alert"><li>' +
|
585
|
+
errorsFound.join("</li><li>") +
|
586
|
+
"</li></ul>" +
|
587
|
+
(settings.options.prependExistingHelpBlock
|
588
|
+
? $helpBlock.data("original-contents")
|
589
|
+
: "")
|
590
|
+
);
|
487
591
|
}
|
488
592
|
} else {
|
489
593
|
$controlGroup.removeClass("warning error success");
|
@@ -498,92 +602,84 @@
|
|
498
602
|
}
|
499
603
|
}
|
500
604
|
);
|
501
|
-
$this.bind("validationLostFocus.validation", function() {
|
605
|
+
$this.bind("validationLostFocus.validation", function () {
|
502
606
|
$controlGroup.removeClass("success");
|
503
607
|
});
|
504
608
|
});
|
505
609
|
},
|
506
|
-
destroy: function() {
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
$helpBlock.attr("role", $this.data("original-role"));
|
526
|
-
// remove all elements we created
|
527
|
-
if (createdElements.indexOf($helpBlock[0]) > -1) {
|
528
|
-
$helpBlock.remove();
|
529
|
-
}
|
530
|
-
|
610
|
+
destroy: function () {
|
611
|
+
return this.each(function () {
|
612
|
+
var $this = $(this),
|
613
|
+
$controlGroup = $this.parents(".form-group").first(),
|
614
|
+
$helpBlock = $controlGroup.find(".help-block").first();
|
615
|
+
|
616
|
+
// remove our events
|
617
|
+
$this.unbind(".validation"); // events are namespaced.
|
618
|
+
// reset help text
|
619
|
+
$helpBlock.html($helpBlock.data("original-contents"));
|
620
|
+
// reset classes
|
621
|
+
$controlGroup.attr("class", $controlGroup.data("original-classes"));
|
622
|
+
// reset aria
|
623
|
+
$this.attr("aria-invalid", $this.data("original-aria-invalid"));
|
624
|
+
// reset role
|
625
|
+
$helpBlock.attr("role", $this.data("original-role"));
|
626
|
+
// remove all elements we created
|
627
|
+
if (createdElements.indexOf($helpBlock[0]) > -1) {
|
628
|
+
$helpBlock.remove();
|
531
629
|
}
|
532
|
-
);
|
533
|
-
|
630
|
+
});
|
534
631
|
},
|
535
|
-
collectErrors: function(includeEmpty) {
|
536
|
-
|
632
|
+
collectErrors: function (includeEmpty) {
|
537
633
|
var errorMessages = {};
|
538
|
-
this.each(function(i, el) {
|
634
|
+
this.each(function (i, el) {
|
539
635
|
var $el = $(el);
|
540
636
|
var name = $el.attr("name");
|
541
637
|
var errors = $el.triggerHandler("validation.validation", {
|
542
|
-
includeEmpty: true
|
638
|
+
includeEmpty: true,
|
543
639
|
});
|
544
640
|
errorMessages[name] = $.extend(true, errors, errorMessages[name]);
|
545
641
|
});
|
546
642
|
|
547
|
-
$.each(errorMessages, function(i, el) {
|
643
|
+
$.each(errorMessages, function (i, el) {
|
548
644
|
if (el.length === 0) {
|
549
645
|
delete errorMessages[i];
|
550
646
|
}
|
551
647
|
});
|
552
648
|
|
553
649
|
return errorMessages;
|
554
|
-
|
555
650
|
},
|
556
|
-
hasErrors: function() {
|
557
|
-
|
651
|
+
hasErrors: function () {
|
558
652
|
var errorMessages = [];
|
559
653
|
|
560
|
-
this.each(function(i, el) {
|
654
|
+
this.each(function (i, el) {
|
561
655
|
errorMessages = errorMessages.concat(
|
562
|
-
$(el).triggerHandler("getValidators.validation")
|
563
|
-
|
564
|
-
|
656
|
+
$(el).triggerHandler("getValidators.validation")
|
657
|
+
? $(el).triggerHandler("validation.validation", {
|
658
|
+
submitting: true,
|
659
|
+
})
|
660
|
+
: []
|
565
661
|
);
|
566
662
|
});
|
567
663
|
|
568
|
-
return
|
664
|
+
return errorMessages.length > 0;
|
569
665
|
},
|
570
|
-
override: function(newDefaults) {
|
666
|
+
override: function (newDefaults) {
|
571
667
|
defaults = $.extend(true, defaults, newDefaults);
|
572
|
-
}
|
668
|
+
},
|
573
669
|
},
|
574
670
|
validatorTypes: {
|
575
671
|
callback: {
|
576
672
|
name: "callback",
|
577
|
-
init: function($this, name) {
|
673
|
+
init: function ($this, name) {
|
578
674
|
return {
|
579
675
|
validatorName: name,
|
580
676
|
callback: $this.data("validation" + name + "Callback"),
|
581
677
|
lastValue: $this.val(),
|
582
678
|
lastValid: true,
|
583
|
-
lastFinished: true
|
679
|
+
lastFinished: true,
|
584
680
|
};
|
585
681
|
},
|
586
|
-
validate: function($this, value, validator) {
|
682
|
+
validate: function ($this, value, validator) {
|
587
683
|
if (validator.lastValue === value && validator.lastFinished) {
|
588
684
|
return !validator.lastValid;
|
589
685
|
}
|
@@ -600,16 +696,19 @@
|
|
600
696
|
window,
|
601
697
|
$this,
|
602
698
|
value,
|
603
|
-
function(data) {
|
699
|
+
function (data) {
|
604
700
|
if (rrjqbvValidator.lastValue === data.value) {
|
605
701
|
rrjqbvValidator.lastValid = data.valid;
|
606
702
|
if (data.message) {
|
607
703
|
rrjqbvValidator.message = data.message;
|
608
704
|
}
|
609
705
|
rrjqbvValidator.lastFinished = true;
|
610
|
-
rrjqbvThis.data(
|
706
|
+
rrjqbvThis.data(
|
707
|
+
"validation" + rrjqbvValidator.validatorName + "Message",
|
708
|
+
rrjqbvValidator.message
|
709
|
+
);
|
611
710
|
// Timeout is set to avoid problems with the events being considered 'already fired'
|
612
|
-
setTimeout(function() {
|
711
|
+
setTimeout(function () {
|
613
712
|
rrjqbvThis.trigger("change.validation");
|
614
713
|
}, 1); // doesn't need a long timeout, just long enough for the event bubble to burst
|
615
714
|
}
|
@@ -618,22 +717,24 @@
|
|
618
717
|
}
|
619
718
|
|
620
719
|
return false;
|
621
|
-
|
622
|
-
}
|
720
|
+
},
|
623
721
|
},
|
624
722
|
ajax: {
|
625
723
|
name: "ajax",
|
626
|
-
init: function($this, name) {
|
724
|
+
init: function ($this, name) {
|
627
725
|
return {
|
628
726
|
validatorName: name,
|
629
727
|
url: $this.data("validation" + name + "Ajax"),
|
630
728
|
lastValue: $this.val(),
|
631
729
|
lastValid: true,
|
632
|
-
lastFinished: true
|
730
|
+
lastFinished: true,
|
633
731
|
};
|
634
732
|
},
|
635
|
-
validate: function($this, value, validator) {
|
636
|
-
if (
|
733
|
+
validate: function ($this, value, validator) {
|
734
|
+
if (
|
735
|
+
"" + validator.lastValue === "" + value &&
|
736
|
+
validator.lastFinished === true
|
737
|
+
) {
|
637
738
|
return validator.lastValid === false;
|
638
739
|
}
|
639
740
|
|
@@ -645,254 +746,305 @@
|
|
645
746
|
url: validator.url,
|
646
747
|
data: "value=" + value + "&field=" + $this.attr("name"),
|
647
748
|
dataType: "json",
|
648
|
-
success: function(data) {
|
749
|
+
success: function (data) {
|
649
750
|
if ("" + validator.lastValue === "" + data.value) {
|
650
|
-
validator.lastValid = !!
|
751
|
+
validator.lastValid = !!data.valid;
|
651
752
|
if (data.message) {
|
652
753
|
validator.message = data.message;
|
653
754
|
}
|
654
755
|
validator.lastFinished = true;
|
655
|
-
$this.data(
|
756
|
+
$this.data(
|
757
|
+
"validation" + validator.validatorName + "Message",
|
758
|
+
validator.message
|
759
|
+
);
|
656
760
|
// Timeout is set to avoid problems with the events being considered 'already fired'
|
657
|
-
setTimeout(function() {
|
761
|
+
setTimeout(function () {
|
658
762
|
$this.trigger("change.validation");
|
659
763
|
}, 1); // doesn't need a long timeout, just long enough for the event bubble to burst
|
660
764
|
}
|
661
765
|
},
|
662
|
-
failure: function() {
|
766
|
+
failure: function () {
|
663
767
|
validator.lastValid = true;
|
664
768
|
validator.message = "ajax call failed";
|
665
769
|
validator.lastFinished = true;
|
666
|
-
$this.data(
|
770
|
+
$this.data(
|
771
|
+
"validation" + validator.validatorName + "Message",
|
772
|
+
validator.message
|
773
|
+
);
|
667
774
|
// Timeout is set to avoid problems with the events being considered 'already fired'
|
668
|
-
setTimeout(function() {
|
775
|
+
setTimeout(function () {
|
669
776
|
$this.trigger("change.validation");
|
670
777
|
}, 1); // doesn't need a long timeout, just long enough for the event bubble to burst
|
671
|
-
}
|
778
|
+
},
|
672
779
|
});
|
673
780
|
}
|
674
781
|
|
675
782
|
return false;
|
676
|
-
|
677
|
-
}
|
783
|
+
},
|
678
784
|
},
|
679
785
|
regex: {
|
680
786
|
name: "regex",
|
681
|
-
init: function($this, name) {
|
787
|
+
init: function ($this, name) {
|
682
788
|
return {
|
683
|
-
regex: regexFromString($this.data("validation" + name + "Regex"))
|
789
|
+
regex: regexFromString($this.data("validation" + name + "Regex")),
|
684
790
|
};
|
685
791
|
},
|
686
|
-
validate: function($this, value, validator) {
|
687
|
-
return (
|
688
|
-
(validator.regex.test(value) && validator.negative)
|
689
|
-
|
792
|
+
validate: function ($this, value, validator) {
|
793
|
+
return (
|
794
|
+
(!validator.regex.test(value) && !validator.negative) ||
|
795
|
+
(validator.regex.test(value) && validator.negative)
|
796
|
+
);
|
797
|
+
},
|
690
798
|
},
|
691
799
|
required: {
|
692
800
|
name: "required",
|
693
|
-
init: function($this, name) {
|
801
|
+
init: function ($this, name) {
|
694
802
|
return {};
|
695
803
|
},
|
696
|
-
validate: function($this, value, validator) {
|
697
|
-
return
|
698
|
-
!!(value.length
|
804
|
+
validate: function ($this, value, validator) {
|
805
|
+
return (
|
806
|
+
!!(value.length === 0 && !validator.negative) ||
|
807
|
+
!!(value.length > 0 && validator.negative)
|
808
|
+
);
|
699
809
|
},
|
700
|
-
blockSubmit: true
|
810
|
+
blockSubmit: true,
|
701
811
|
},
|
702
812
|
match: {
|
703
813
|
name: "match",
|
704
|
-
init: function($this, name) {
|
705
|
-
var element = $this
|
706
|
-
|
814
|
+
init: function ($this, name) {
|
815
|
+
var element = $this
|
816
|
+
.parents("form")
|
817
|
+
.first()
|
818
|
+
.find('[name="' + $this.data("validation" + name + "Match") + '"]')
|
819
|
+
.first();
|
820
|
+
element.bind("validation.validation", function () {
|
707
821
|
$this.trigger("change.validation", {
|
708
|
-
submitting: true
|
822
|
+
submitting: true,
|
709
823
|
});
|
710
824
|
});
|
711
825
|
return {
|
712
|
-
|
826
|
+
element: element,
|
713
827
|
};
|
714
828
|
},
|
715
|
-
validate: function($this, value, validator) {
|
716
|
-
return (
|
717
|
-
(value
|
829
|
+
validate: function ($this, value, validator) {
|
830
|
+
return (
|
831
|
+
(value !== validator.element.val() && !validator.negative) ||
|
832
|
+
(value === validator.element.val() && validator.negative)
|
833
|
+
);
|
718
834
|
},
|
719
|
-
blockSubmit: true
|
835
|
+
blockSubmit: true,
|
720
836
|
},
|
721
837
|
max: {
|
722
838
|
name: "max",
|
723
|
-
init: function($this, name) {
|
839
|
+
init: function ($this, name) {
|
724
840
|
return {
|
725
|
-
max: $this.data("validation" + name + "Max")
|
841
|
+
max: $this.data("validation" + name + "Max"),
|
726
842
|
};
|
727
843
|
},
|
728
|
-
validate: function($this, value, validator) {
|
729
|
-
return (
|
730
|
-
(parseFloat(value, 10)
|
731
|
-
|
844
|
+
validate: function ($this, value, validator) {
|
845
|
+
return (
|
846
|
+
(parseFloat(value, 10) > parseFloat(validator.max, 10) &&
|
847
|
+
!validator.negative) ||
|
848
|
+
(parseFloat(value, 10) <= parseFloat(validator.max, 10) &&
|
849
|
+
validator.negative)
|
850
|
+
);
|
851
|
+
},
|
732
852
|
},
|
733
853
|
min: {
|
734
854
|
name: "min",
|
735
|
-
init: function($this, name) {
|
855
|
+
init: function ($this, name) {
|
736
856
|
return {
|
737
|
-
min: $this.data("validation" + name + "Min")
|
857
|
+
min: $this.data("validation" + name + "Min"),
|
738
858
|
};
|
739
859
|
},
|
740
|
-
validate: function($this, value, validator) {
|
741
|
-
return (
|
742
|
-
(parseFloat(value)
|
743
|
-
|
860
|
+
validate: function ($this, value, validator) {
|
861
|
+
return (
|
862
|
+
(parseFloat(value) < parseFloat(validator.min) &&
|
863
|
+
!validator.negative) ||
|
864
|
+
(parseFloat(value) >= parseFloat(validator.min) &&
|
865
|
+
validator.negative)
|
866
|
+
);
|
867
|
+
},
|
744
868
|
},
|
745
869
|
maxlength: {
|
746
870
|
name: "maxlength",
|
747
|
-
init: function($this, name) {
|
871
|
+
init: function ($this, name) {
|
748
872
|
return {
|
749
|
-
maxlength: $this.data("validation" + name + "Maxlength")
|
873
|
+
maxlength: $this.data("validation" + name + "Maxlength"),
|
750
874
|
};
|
751
875
|
},
|
752
|
-
validate: function($this, value, validator) {
|
753
|
-
return (
|
754
|
-
(
|
755
|
-
|
876
|
+
validate: function ($this, value, validator) {
|
877
|
+
return (
|
878
|
+
(value.length > validator.maxlength && !validator.negative) ||
|
879
|
+
(value.length <= validator.maxlength && validator.negative)
|
880
|
+
);
|
881
|
+
},
|
756
882
|
},
|
757
883
|
minlength: {
|
758
884
|
name: "minlength",
|
759
|
-
init: function($this, name) {
|
885
|
+
init: function ($this, name) {
|
760
886
|
return {
|
761
|
-
minlength: $this.data("validation" + name + "Minlength")
|
887
|
+
minlength: $this.data("validation" + name + "Minlength"),
|
762
888
|
};
|
763
889
|
},
|
764
|
-
validate: function($this, value, validator) {
|
765
|
-
return (
|
766
|
-
(
|
767
|
-
|
890
|
+
validate: function ($this, value, validator) {
|
891
|
+
return (
|
892
|
+
(value.length < validator.minlength && !validator.negative) ||
|
893
|
+
(value.length >= validator.minlength && validator.negative)
|
894
|
+
);
|
895
|
+
},
|
768
896
|
},
|
769
897
|
maxchecked: {
|
770
898
|
name: "maxchecked",
|
771
|
-
init: function($this, name) {
|
772
|
-
var elements = $this
|
773
|
-
|
899
|
+
init: function ($this, name) {
|
900
|
+
var elements = $this
|
901
|
+
.parents("form")
|
902
|
+
.first()
|
903
|
+
.find('[name="' + $this.attr("name") + '"]');
|
904
|
+
elements.bind("click.validation", function () {
|
774
905
|
$this.trigger("change.validation", {
|
775
|
-
includeEmpty: true
|
906
|
+
includeEmpty: true,
|
776
907
|
});
|
777
908
|
});
|
778
909
|
return {
|
779
910
|
maxchecked: $this.data("validation" + name + "Maxchecked"),
|
780
|
-
elements: elements
|
911
|
+
elements: elements,
|
781
912
|
};
|
782
913
|
},
|
783
|
-
validate: function($this, value, validator) {
|
784
|
-
return (
|
785
|
-
(validator.elements.filter(":checked").length
|
914
|
+
validate: function ($this, value, validator) {
|
915
|
+
return (
|
916
|
+
(validator.elements.filter(":checked").length >
|
917
|
+
validator.maxchecked &&
|
918
|
+
!validator.negative) ||
|
919
|
+
(validator.elements.filter(":checked").length <=
|
920
|
+
validator.maxchecked &&
|
921
|
+
validator.negative)
|
922
|
+
);
|
786
923
|
},
|
787
|
-
blockSubmit: true
|
924
|
+
blockSubmit: true,
|
788
925
|
},
|
789
926
|
minchecked: {
|
790
927
|
name: "minchecked",
|
791
|
-
init: function($this, name) {
|
792
|
-
var elements = $this
|
793
|
-
|
928
|
+
init: function ($this, name) {
|
929
|
+
var elements = $this
|
930
|
+
.parents("form")
|
931
|
+
.first()
|
932
|
+
.find('[name="' + $this.attr("name") + '"]');
|
933
|
+
elements.bind("click.validation", function () {
|
794
934
|
$this.trigger("change.validation", {
|
795
|
-
includeEmpty: true
|
935
|
+
includeEmpty: true,
|
796
936
|
});
|
797
937
|
});
|
798
938
|
return {
|
799
939
|
minchecked: $this.data("validation" + name + "Minchecked"),
|
800
|
-
elements: elements
|
940
|
+
elements: elements,
|
801
941
|
};
|
802
942
|
},
|
803
|
-
validate: function($this, value, validator) {
|
804
|
-
return (
|
805
|
-
(validator.elements.filter(":checked").length
|
943
|
+
validate: function ($this, value, validator) {
|
944
|
+
return (
|
945
|
+
(validator.elements.filter(":checked").length <
|
946
|
+
validator.minchecked &&
|
947
|
+
!validator.negative) ||
|
948
|
+
(validator.elements.filter(":checked").length >=
|
949
|
+
validator.minchecked &&
|
950
|
+
validator.negative)
|
951
|
+
);
|
806
952
|
},
|
807
|
-
blockSubmit: true
|
808
|
-
}
|
953
|
+
blockSubmit: true,
|
954
|
+
},
|
809
955
|
},
|
810
956
|
builtInValidators: {
|
811
957
|
email: {
|
812
958
|
name: "Email",
|
813
959
|
type: "shortcut",
|
814
|
-
shortcut: "validemail"
|
960
|
+
shortcut: "validemail",
|
815
961
|
},
|
816
962
|
validemail: {
|
817
963
|
name: "Validemail",
|
818
964
|
type: "regex",
|
819
|
-
regex: "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]
|
820
|
-
message:
|
965
|
+
regex: "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}",
|
966
|
+
message:
|
967
|
+
"Not a valid email address<!-- data-validator-validemail-message to override -->",
|
821
968
|
},
|
822
969
|
passwordagain: {
|
823
970
|
name: "Passwordagain",
|
824
971
|
type: "match",
|
825
972
|
match: "password",
|
826
|
-
message:
|
973
|
+
message:
|
974
|
+
"Does not match the given password<!-- data-validator-paswordagain-message to override -->",
|
827
975
|
},
|
828
976
|
positive: {
|
829
977
|
name: "Positive",
|
830
978
|
type: "shortcut",
|
831
|
-
shortcut: "number,positivenumber"
|
979
|
+
shortcut: "number,positivenumber",
|
832
980
|
},
|
833
981
|
negative: {
|
834
982
|
name: "Negative",
|
835
983
|
type: "shortcut",
|
836
|
-
shortcut: "number,negativenumber"
|
984
|
+
shortcut: "number,negativenumber",
|
837
985
|
},
|
838
986
|
number: {
|
839
987
|
name: "Number",
|
840
988
|
type: "regex",
|
841
|
-
regex: "([+-]
|
842
|
-
message:
|
989
|
+
regex: "([+-]?\\d+(\\.\\d*)?([eE][+-]?[0-9]+)?)?",
|
990
|
+
message:
|
991
|
+
"Must be a number<!-- data-validator-number-message to override -->",
|
843
992
|
},
|
844
993
|
integer: {
|
845
994
|
name: "Integer",
|
846
995
|
type: "regex",
|
847
|
-
regex: "[+-]
|
848
|
-
message:
|
996
|
+
regex: "[+-]?\\d+",
|
997
|
+
message:
|
998
|
+
"No decimal places allowed<!-- data-validator-integer-message to override -->",
|
849
999
|
},
|
850
1000
|
positivenumber: {
|
851
1001
|
name: "Positivenumber",
|
852
1002
|
type: "min",
|
853
1003
|
min: 0,
|
854
|
-
message:
|
1004
|
+
message:
|
1005
|
+
"Must be a positive number<!-- data-validator-positivenumber-message to override -->",
|
855
1006
|
},
|
856
1007
|
negativenumber: {
|
857
1008
|
name: "Negativenumber",
|
858
1009
|
type: "max",
|
859
1010
|
max: 0,
|
860
|
-
message:
|
1011
|
+
message:
|
1012
|
+
"Must be a negative number<!-- data-validator-negativenumber-message to override -->",
|
861
1013
|
},
|
862
1014
|
required: {
|
863
1015
|
name: "Required",
|
864
1016
|
type: "required",
|
865
|
-
message:
|
1017
|
+
message:
|
1018
|
+
"This is required<!-- data-validator-required-message to override -->",
|
866
1019
|
},
|
867
1020
|
checkone: {
|
868
1021
|
name: "Checkone",
|
869
1022
|
type: "minchecked",
|
870
1023
|
minchecked: 1,
|
871
|
-
message:
|
872
|
-
|
873
|
-
|
1024
|
+
message:
|
1025
|
+
"Check at least one option<!-- data-validation-checkone-message to override -->",
|
1026
|
+
},
|
1027
|
+
},
|
874
1028
|
};
|
875
1029
|
|
876
|
-
var formatValidatorName = function(name) {
|
877
|
-
return name
|
878
|
-
.
|
879
|
-
|
880
|
-
/(^|\s)([a-z])/g,
|
881
|
-
function(m, p1, p2) {
|
882
|
-
return p1 + p2.toUpperCase();
|
883
|
-
}
|
884
|
-
);
|
1030
|
+
var formatValidatorName = function (name) {
|
1031
|
+
return name.toLowerCase().replace(/(^|\s)([a-z])/g, function (m, p1, p2) {
|
1032
|
+
return p1 + p2.toUpperCase();
|
1033
|
+
});
|
885
1034
|
};
|
886
1035
|
|
887
|
-
var getValue = function($this) {
|
1036
|
+
var getValue = function ($this) {
|
888
1037
|
// Extract the value we're talking about
|
889
1038
|
var value = $this.val();
|
890
1039
|
var type = $this.attr("type");
|
891
1040
|
if (type === "checkbox") {
|
892
|
-
value =
|
1041
|
+
value = $this.is(":checked") ? value : "";
|
893
1042
|
}
|
894
1043
|
if (type === "radio") {
|
895
|
-
value =
|
1044
|
+
value =
|
1045
|
+
$('input[name="' + $this.attr("name") + '"]:checked').length > 0
|
1046
|
+
? value
|
1047
|
+
: "";
|
896
1048
|
}
|
897
1049
|
return value;
|
898
1050
|
};
|
@@ -907,7 +1059,7 @@
|
|
907
1059
|
* http://stackoverflow.com/questions/359788/how-to-execute-a-javascript-function-when-i-have-its-name-as-a-string#answer-359910
|
908
1060
|
* Short link: http://tinyurl.com/executeFunctionByName
|
909
1061
|
**/
|
910
|
-
function executeFunctionByName(functionName, context /*, args*/
|
1062
|
+
function executeFunctionByName(functionName, context /*, args*/) {
|
911
1063
|
var args = Array.prototype.slice.call(arguments).splice(2);
|
912
1064
|
var namespaces = functionName.split(".");
|
913
1065
|
var func = namespaces.pop();
|
@@ -917,21 +1069,25 @@
|
|
917
1069
|
return context[func].apply(this, args);
|
918
1070
|
}
|
919
1071
|
|
920
|
-
$.fn.jqBootstrapValidation = function(method) {
|
921
|
-
|
1072
|
+
$.fn.jqBootstrapValidation = function (method) {
|
922
1073
|
if (defaults.methods[method]) {
|
923
|
-
return defaults.methods[method].apply(
|
924
|
-
|
1074
|
+
return defaults.methods[method].apply(
|
1075
|
+
this,
|
1076
|
+
Array.prototype.slice.call(arguments, 1)
|
1077
|
+
);
|
1078
|
+
} else if (typeof method === "object" || !method) {
|
925
1079
|
return defaults.methods.init.apply(this, arguments);
|
926
1080
|
} else {
|
927
|
-
$.error(
|
1081
|
+
$.error(
|
1082
|
+
"Method " + method + " does not exist on jQuery.jqBootstrapValidation"
|
1083
|
+
);
|
928
1084
|
return null;
|
929
1085
|
}
|
930
|
-
|
931
1086
|
};
|
932
1087
|
|
933
|
-
$.jqBootstrapValidation = function(options) {
|
934
|
-
$(":input")
|
1088
|
+
$.jqBootstrapValidation = function (options) {
|
1089
|
+
$(":input")
|
1090
|
+
.not("[type=image],[type=submit]")
|
1091
|
+
.jqBootstrapValidation.apply(this, arguments);
|
935
1092
|
};
|
936
|
-
|
937
1093
|
})(jQuery);
|