Skip to content

Commit 3cc037e

Browse files
committed
Ready to release tag 1.3.0
1 parent b9f0030 commit 3cc037e

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

jquery.validation.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* jQuery Form Validation
33
*
44
* @author Tom Bertrand
5-
* @version 1.3.0 (2014-07-24)
5+
* @version 1.3.0 (2014-07-25)
66
*
77
* @copyright
88
* Copyright (C) 2014 Tom Bertrand.
@@ -457,6 +457,8 @@
457457
*/
458458
function validateForm () {
459459

460+
var isValid = true;
461+
460462
$.each(
461463
$(node).find('[' + _data.validation + '],[' + _data.regex + ']'),
462464
function (index, input) {
@@ -465,12 +467,14 @@
465467
return false;
466468
}
467469

468-
validateInput(input);
470+
if (!validateInput(input)) {
471+
isValid = false;
472+
}
469473

470474
}
471475
);
472476

473-
return $.isEmptyObject(errors);
477+
return isValid;
474478

475479
}
476480

@@ -515,7 +519,7 @@
515519
}
516520

517521
// Validates the "data-validation"
518-
if (!$.isEmptyObject(validationArray)) {
522+
if (validationArray instanceof Array && validationArray.length > 0) {
519523

520524
// "OPTIONAL" input will not be validated if it's empty
521525
if (value === '' && $.inArray('OPTIONAL', validationArray) !== -1) {
@@ -590,6 +594,7 @@
590594
'message': 'WARNING - Invalid [data-validation-regex] on input ' + inputName
591595
});
592596

597+
// Do not block validation if a regexp is bad, only skip it
593598
return true;
594599

595600
}
@@ -608,7 +613,7 @@
608613

609614
}
610615

611-
return $.isEmptyObject(errors[inputName]);
616+
return !errors[inputName] || errors[inputName] instanceof Array && errors[inputName].length === 0;
612617

613618
}
614619

@@ -835,6 +840,11 @@
835840
errorContainer = $(node);
836841
}
837842

843+
// Prevent double error list if the previous one has not been cleared.
844+
if (options.submit.settings.display === 'inline' && errorContainer.find('[' + _data.errorList + ']')[0]) {
845+
return false;
846+
}
847+
838848
if (options.submit.settings.display === "inline" ||
839849
(options.submit.settings.display === "block" && !errorContainer.find('[' + _data.errorList + ']')[0])
840850
) {
@@ -870,13 +880,10 @@
870880
input.unbind(event).on(event, function (a,b,c,d,e) {
871881

872882
return function () {
873-
874883
if (e) {
875-
876884
if ($(c).hasClass(options.submit.settings.errorClass)) {
877885
resetOneError(a,b,c,d,e);
878886
}
879-
880887
} else if ($(b).hasClass(options.submit.settings.errorClass)) {
881888
resetOneError(a,b,c,d);
882889
}
@@ -1466,7 +1473,7 @@
14661473
return false;
14671474
}
14681475

1469-
if (typeof error !== "object" || $.isEmptyObject(error) || Object.prototype.toString.call(error) !== "[object Object]") {
1476+
if (typeof error !== "object" || Object.prototype.toString.call(error) !== "[object Object]") {
14701477
window.debug('$.addError - Invalid error object.');
14711478
return false;
14721479
}
@@ -1518,7 +1525,7 @@
15181525
* Note: The same form jQuery selector MUST be used to recuperate the Validation configuration.
15191526
*
15201527
* @example
1521-
* $('#form-signup_v3').removeError([
1528+
* $('#form-signin_v2').removeError([
15221529
* 'signin_v2[username]',
15231530
* 'signin_v2[password]'
15241531
* ])
@@ -1540,7 +1547,7 @@
15401547
return false;
15411548
}
15421549

1543-
if (typeof inputName === "object" && ($.isEmptyObject(inputName) || Object.prototype.toString.call(inputName) !== "[object Array]")) {
1550+
if (typeof inputName === "object" && Object.prototype.toString.call(inputName) !== "[object Array]") {
15441551
window.debug('$.removeError - Invalid inputName array.');
15451552
return false;
15461553
}
@@ -1579,7 +1586,7 @@
15791586

15801587
window.Debug = {
15811588

1582-
table: [],
1589+
table: {},
15831590
log: function (debugObject) {
15841591

15851592
if (!debugObject.message || typeof debugObject.message !== "string") {
@@ -1621,7 +1628,7 @@
16211628
console.log('Debug is not available on your current browser, try the most recent version of Chrome or Firefox.');
16221629
}
16231630

1624-
this.table = [];
1631+
this.table = {};
16251632

16261633
}
16271634

0 commit comments

Comments
 (0)