Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 74b97af

Browse files
committed
suppress error messages from Validator if there are no fields available for validation
1 parent 11317ba commit 74b97af

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/validator/validator.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,7 @@
251251
fire = form.add(self);
252252

253253
// make sure there are input fields available
254-
inputs = inputs.not(":button, :image, :reset, :submit");
255-
if (!inputs.length) { throw "Validator: no input fields supplied"; }
254+
inputs = inputs.not(":button, :image, :reset, :submit");
256255

257256
// utility function
258257
function pushMessage(to, matcher, returnValue) {
@@ -465,7 +464,7 @@
465464
}
466465

467466
// disable browser's default validation mechanism
468-
if (inputs.get(0).validity) {
467+
if (inputs[0] && inputs[0].validity) {
469468
inputs.each(function() {
470469
this.oninvalid = function() {
471470
return false;

test/validator/no-form.htm

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@
5252
</div>
5353

5454
<script>
55-
var inputs = $(".form :input").validator();
56-
57-
5855
// perform validation programmatically
59-
console.info(inputs, inputs.data("validator"), inputs.data("validator").checkValidity());
56+
var inputs = $(".form :input").validator();
57+
inputs.data("validator").checkValidity();
6058
</script>

0 commit comments

Comments
 (0)