Skip to content

Commit

Permalink
Update Form.Validator.Extras.js
Browse files Browse the repository at this point in the history
Bugfix to validate-reqchk-byname - not hiding error messages properly when one checkbox is unchecked, producing an eror underneath it, then another checkbox is checked, and the previous error doesn't go away.
example: http://jsfiddle.net/aUFe4/1/

Update Form.Validator.Extras.js

Bugfix to validate-reqchk-byname - not hiding error messages properly when one checkbox is unchecked, producing an eror underneath it, then another checkbox is checked, and the previous error doesn't go away.
example: http://jsfiddle.net/aUFe4/1/

Added feature validate-enforce-onselect-value

validate-enforce-onselect-value - enables the user to specify when a select value is selected, to enforce / ignore fields

remove some unessential code + tab indent cleanup

remove some unessential code + tab indent cleanup
  • Loading branch information
ntom authored and SergioCrisostomo committed Oct 25, 2015
1 parent a28974f commit 670f4b1
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Source/Forms/Form.Validator.Extras.js
Expand Up @@ -52,6 +52,23 @@ Form.Validator.addAllThese([
return true;
}
}],

['validate-enforce-onselect-value', {
test: function(element, props){
if( !props.value ) return true;
var fv = element.getParent('form').retrieve('validator');
if (!fv) return true;
(props.toEnforce || document.id(props.enforceChildrenOf).getElements('input, select, textarea')).map(function(item){
if (props.value == element.value){
fv.enforceField(item);
} else {
fv.ignoreField(item);
fv.resetField(item);
}
});
return true;
}
}],

['validate-nospace', {
errorMsg: function(){
Expand Down Expand Up @@ -107,11 +124,14 @@ Form.Validator.addAllThese([
},
test: function(element, props){
var grpName = props.groupName || element.get('name');
var oneCheckedItem = $$(document.getElementsByName(grpName)).some(function(item, index){
var grpNameEls = $$('[name=' + grpName +']');
var oneCheckedItem = grpNameEls.some(function(item, index){
return item.checked;
});
var fv = element.getParent('form').retrieve('validator');
if (oneCheckedItem && fv) fv.resetField(element);
if (oneCheckedItem && fv) {
grpNameEls.each(function(item, index) { fv.resetField(item); });
}
return oneCheckedItem;
}
}],
Expand Down

0 comments on commit 670f4b1

Please sign in to comment.