* @private
*/
Abide.prototype._init = function(){
- this.$inputs = this.$element.find('input, textarea, select').not('[data-abide-ignore]');
+ this.$inputs = this.$element.find('input, textarea, select').not('[data-abide-ignore], :radio, :checkbox');
+ this.$ticks = this.$element.find(':radio, :checkbox');
+ if(this.$ticks.length) this._checkTicks()
this.radioRequiredGroups();
this._events();
};
+ Abide.prototype._checkTicks = function(){
+ var names = [];
+ this.$ticks.each(function(){
+ if(this.name && names.indexOf(this.name) === -1) names.push(this.name);
+ })
+ console.log(names);
+ // this.$sets = this.$ticks.map(function(){
+ // var box = $(this);
+ // return $('[name=]')
+ // })
+ };
/**
* Initializes events for Abide.
var acc = [],
_this = this;
+ if(this.$ticks.length){
+ // this.validateTicks();
+ // this.$ticks.each(function(){
+ // acc.push(_this.validateTicks($(this)));
+ // });
+ }
this.$inputs.each(function(){
acc.push(_this.validateInput($(this)));
});
return noError;
};
+ Abide.prototype.validateTicks = function($el, name){
+ // $el = $el === undefined ? this.$element : $el;
+ // var group = $el.find('[name="'+name+'"]');
+ // if
+ };
/**
* Determines whether or a not a text input is valid based on the pattern specified in the attribute. If no matching pattern is found, returns true.
* @param {Object} $el - jQuery object to validate, should be a text input HTML element
return inputText.length ?//if text, check if the pattern exists, if so, test it, if no text or no pattern, return true.
this.options.patterns.hasOwnProperty(pattern) ? this.options.patterns[pattern].test(inputText) :
- pattern && pattern!=$el.attr('type') ? new RegExp(pattern).test(inputText) : true : true;
+ pattern && pattern !== $el.attr('type') ? new RegExp(pattern).test(inputText) : true : true;
};
/**
* Determines whether or a not a radio input is valid based on whether or not it is required and selected
* @returns {Boolean} Boolean value depends on whether or not at least one radio input has been selected (if it's required)
*/
Abide.prototype.validateRadio = function(groupName){
- if(this.radioRequiredGroups.indexOf(groupName)===-1) return true;
+ if(this.radioRequiredGroups.indexOf(groupName) === -1) return true;
var $group = this.$element.find(':radio[name="' + groupName + '"]'),
labels = [],
counter = false,
- self = this;
+ _this = this;
$group.each(function(){
- labels.push(self.findLabel($(this)));
+ labels.push(_this.findLabel($(this)));
if(this.checked){
counter = true;
}
});
if (counter) {
for(var i = 0, len = labels.length; i < len; i++){
- self.removeErrorClasses(labels[i]);
+ _this.removeErrorClasses(labels[i]);
};
};
return counter;
* Build radioRequiredGroups for validateRadio required check
*/
Abide.prototype.radioRequiredGroups = function() {
- var self = this;
- self.radioRequiredGroups = [];
+ var _this = this;
+ _this.radioRequiredGroups = [];
- self.$inputs.filter(':radio').each(function(){
- this.required && self.radioRequiredGroups.indexOf(this.name)===-1?self.radioRequiredGroups.push(this.name):false;
+ _this.$inputs.filter(':radio').each(function(){
+ console.log(this);
+ this.required && _this.radioRequiredGroups.indexOf(this.name)===-1?_this.radioRequiredGroups.push(this.name):false;
});
};
/**