13:ba58d75904e4
Anton Shestakov <av6@dwimlabs.net>, Sat, 19 Mar 2016 10:46:01 +0800
provision: service checks

previous change 11:082343e93ae6

js/ui/validation.js

Permissions: -rw-r--r--

Other formats: Feeds:
// Generated by CoffeeScript 1.10.0
(function() {
var Validation;
Validation = (function() {
function Validation() {}
Validation.prototype.setError = function($field, message) {
var $el;
$el = $('<div class="uk-text-danger"></div>').text(message);
$field.addClass('uk-form-danger');
return $field.after($el);
};
Validation.prototype.unsetError = function($field) {
return $field.removeClass('uk-form-danger').siblings('.uk-text-danger').remove();
};
Validation.prototype.validateRequired = function(field, trim) {
var $field, val;
$field = $(field);
val = $field.val();
if (trim) {
val = val.trim();
}
if (val === '') {
this.setError($field, 'This field is required.');
return false;
} else {
return true;
}
};
Validation.prototype.validatePasswords = function(field1, field2) {
var $field1, $field2;
$field1 = $(field1);
$field2 = $(field2);
if ($field1.val() !== $field2.val()) {
this.setError($field2, 'Passwords must match.');
return false;
} else {
return true;
}
};
return Validation;
})();
window.validation = new Validation();
}).call(this);
//# sourceMappingURL=validation.js.map