Skip to content

Commit c572703

Browse files
author
t_bertrand
committed
- Default type="submit" is not an imput anymore
- Don't validate readonly or disabled inputs - Make sure the notre is a "form" else drop validation
1 parent e27fb7e commit c572703

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

jquery.validation.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
insertion: "append",
122122
allErrors: false,
123123
trigger: "click",
124-
button: "input[type='submit']",
124+
button: "[type='submit']",
125125
errorClass: "error",
126126
errorListClass: "error-list",
127127
inputContainer: null,
@@ -478,7 +478,7 @@
478478
var isValid = true;
479479

480480
$.each(
481-
node.find('[' + _data.validation + '],[' + _data.regex + ']'),
481+
node.find('[' + _data.validation + ']:not([readonly], [disabled]),[' + _data.regex + ']:not([readonly], [disabled])'),
482482
function (index, input) {
483483

484484
if ($(this).is(':disabled')) {
@@ -747,7 +747,7 @@
747747
}
748748

749749
} else {
750-
// Compare numeric value
750+
// Compare numeric value
751751
if (!value || isNaN(value) || !eval(value + operator + parseFloat(compared))) {
752752
throw [options.messages[operator].replace(' characters', ''), compared];
753753
}
@@ -879,7 +879,7 @@
879879

880880
if (options.submit.settings.display === "inline" ||
881881
(options.submit.settings.display === "block" && !errorContainer.find('[' + _data.errorList + ']')[0])
882-
) {
882+
) {
883883
if (options.submit.settings.insertion === 'append') {
884884
errorContainer.append(html);
885885
} else if (options.submit.settings.insertion === 'prepend') {
@@ -1433,11 +1433,10 @@
14331433

14341434
node = $(options.submit.settings.form);
14351435

1436-
if (!node[0]) {
1436+
if (!node[0] || node[0].nodeName.toLowerCase() !== "form") {
14371437

14381438
// {debug}
14391439
window.Debug.log({
1440-
'node': node,
14411440
'function': '$.validate()',
14421441
'arguments': JSON.stringify(options.submit.settings.form),
14431442
'message': 'Unable to find jQuery form element - Validation dropped'

0 commit comments

Comments
 (0)