summaryrefslogtreecommitdiff
path: root/horizon/static/horizon/js/horizon.users.js
blob: 41b23b31800b54431b352a8f904d27105908d57d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
horizon.user = {

  init: function() {
    $("#id_password").change(function () {
      if ($("#id_confirm_password").val() != "") {
        horizon.user.check_passwords_match();
      }
    });

    $("#id_confirm_password").change(function () {
      horizon.user.check_passwords_match();
    });
  },

  check_passwords_match: function() {
    var row = $("label[for='id_confirm_password']");
    var error_id = "id_confirm_password_error";
    var msg = "<span id='" + error_id + "' class='help-inline'>" + gettext("Passwords do not match.") + "</span>";

    var password = $("#id_password").val();
    var confirm_password = $("#id_confirm_password").val();

    if (password != confirm_password && $("#" + error_id).length == 0) {
      $(row).parent().addClass("error");
      $(row).after(msg);
    } else if (password == confirm_password) {
      $(row).parent().removeClass("error");
      $("#" + error_id).remove();
    }
  }
};