Skip to content

Commit

Permalink
fixing up minchecked validator
Browse files Browse the repository at this point in the history
  • Loading branch information
ReactiveRaven committed Jan 14, 2013
1 parent b792747 commit eba9ade
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/jqBootstrapValidation.js
Original file line number Diff line number Diff line change
@@ -887,22 +887,35 @@
return (validator.elements.filter(":checked").length > validator.maxchecked && ! validator.negative) ||
(validator.elements.filter(":checked").length <= validator.maxchecked && validator.negative);
},
blockSubmit: true
blockSubmit: true
},
minchecked: {
name: "minchecked",
init: function ($this, name) {
var result = {};

var elements = $this.parents("form").first().find("[name=\"" + $this.attr("name") + "\"]");
elements.bind("click.validation", function () {
elements.bind("change.validation click.validation", function () {
$this.trigger("revalidate.validation", {includeEmpty: true});
});
return {minchecked: $this.data("validation" + name + "Minchecked"), elements: elements};

result.elements = elements;
result.minchecked = $this.data("validation" + name + "Minchecked");

var message = "Too few: Min '" + result.minchecked + "' checked";
if ($this.data("validation" + name + "Message")) {
message = $this.data("validation" + name + "Message");
}
result.message = message;

return result;
},
validate: function ($this, value, validator) {
return (validator.elements.filter(":checked").length < validator.minchecked && ! validator.negative) ||
(validator.elements.filter(":checked").length >= validator.minchecked && validator.negative);
},
blockSubmit: true
blockSubmit: true,
includeEmpty: true
},
number: {
name: "number",

0 comments on commit eba9ade

Please sign in to comment.