Files
zulip/zephyr/static/js/signup.js
Keegan McAllister 01a20d9c56 signup: Don't display password validation message immediately
We now have the bar color to indicate (for most users) whether the password is
valid, so revert to the default validation behavior and don't validate before
the first blur.

(imported from commit 5c2f6e05a8796033942a2af62f244b61459ff1bb)
2013-04-10 18:05:02 -04:00

50 lines
1.5 KiB
JavaScript

$(function () {
// NB: this file is included on multiple pages. In each context,
// some of the jQuery selectors below will return empty lists.
$.validator.addMethod('password', function (value, element) {
return password_quality(value);
}, 'Password is weak.');
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({
rules: {
id_password: 'password'
},
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')
});
$('#id_password').on('change keyup', function () {
// Update the password strength bar even if we aren't validating
// the field yet.
password_quality($('#id_password').val(), $('#pw_strength .bar'));
});
$("#send_confirm").validate({
errorElement: "p",
errorPlacement: function (error, element) {
$('#errors').empty();
error.appendTo("#errors")
.addClass("text-error");
},
success: function () {
$('#errors').empty();
}
});
});