Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/assets/netteForms.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ Nette.validateControl = function(elem, rules, onlyCheck, value) {

if (rule.condition && success) {
if (!Nette.validateControl(elem, rule.rules, onlyCheck, value)) {
Nette.markControlInvalid(elem);
return false;
}
} else if (!rule.condition && !success) {
Expand All @@ -140,13 +141,35 @@ Nette.validateControl = function(elem, rules, onlyCheck, value) {
});
Nette.addError(curElem, message);
}
Nette.markControlInvalid(elem);
return false;
}
}
Nette.markControlValid(elem);
return true;
};


Nette.markControlValid = function(elem) {
Nette.switchClass(elem, 'nette-control-invalid', 'nette-control-valid');
};


Nette.markControlInvalid = function(elem) {
Nette.switchClass(elem, 'nette-control-valid', 'nette-control-invalid');
};


Nette.switchClass = function(elem, remove, add) {
if (typeof elem.classList === 'undefined') { // not supported in IE < 10 , Opera Mini 8
return;
}

elem.classList.remove(remove);
elem.classList.add(add);
};


/**
* Validates whole form.
*/
Expand Down