Add custom callbacks handler

Fix typo
This commit is contained in:
Nicolas Le Goff
2013-06-11 12:42:45 +02:00
parent c990da08ec
commit 39be3c7b1f
6 changed files with 11 additions and 8 deletions

View File

@@ -9,7 +9,6 @@
"modernizr": "~2.6.2",
"normalize-css" : "~2.1.0",
"json3" : "3.2.4",
"bootstrap-switch": "https://github.com/nostalgiaz/bootstrap-switch.git",
"humane-js": "~3.0.6",
"qunit": "https://github.com/jquery/qunit.git#1.11.0",
"mustache": "~0.7.2",

View File

@@ -14,9 +14,11 @@ define([
], function($, _, Backbone) {
var FormValidator = function(rules) {
var FormValidator = function(rules, handlers) {
// rules setted by user
this.rules = rules || [];
// custom callbacks
this.handlers = handlers || [];
// final fields to validate
this.fields = [];
@@ -162,7 +164,11 @@ define([
return field.value === defaultName;
},
"matches": function(field, matchName) {
var el = this.inputs[matchName];
if (typeof this.inputs[matchName] === "undefined") {
return false;
}
var el = this.inputs[matchName].shift();
if (el) {
return field.value === el.value;

View File

@@ -491,5 +491,3 @@ define([
});
});
});