Files
zulip/zephyr/static/js/signup.js
Keegan McAllister 447dc0029a signup: Fix and clean up validation highlighting
Fixes #1154.

(imported from commit f50a3cb24d66e09b768e4e0702308c1c7f2c51d9)
2013-04-10 18:04:59 -04:00

34 lines
1003 B
JavaScript

$(function () {
function highlight(class_to_add) {
// Set a class on the enclosing control group.
return function (element) {
$(element).closest('.control-group')
.removeClass('success error')
.addClass(class_to_add);
};
}
$('#registration').validate({
errorElement: "p",
errorPlacement: function (error, element) {
// NB: this is called at most once, when the error element
// is created.
error.insertAfter(element).addClass('help-inline');
},
highlight: highlight('error'),
unhighlight: highlight('success')
});
$("#send_confirm").validate({
errorElement: "p",
errorPlacement: function (error, element) {
$('#errors').empty();
error.appendTo("#errors")
.addClass("text-error");
},
success: function () {
$('#errors').empty();
}
});
});