security.js 1 KB
Newer Older
Rosanny Sihombing's avatar
Rosanny Sihombing committed
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
// check password and password confirmation input fields
// used in Security and Reset Password
$('#inputNewPwd, #inputConfirm').on('keyup', function () {
  let isBest, isMatch

  isBest = checkPasswordReq($('#inputNewPwd').val())
  $('#recommendation').empty()
  if (!isBest) {
    // $('#recommendation').html('Must be at least 8 characters').css('color', 'red');
    $('#recommendation').html('Das Passwort muss mindestens 8 Zeichen haben').css('color', 'red')
  }

  // match or not?
  if ($('#inputNewPwd').val() === $('#inputConfirm').val()) {
    // $('#message').html('Matching').css('color', 'green');
    $('#message').html('Übereinstimmend').css('color', 'green')
    isMatch = true
  } else {
    // $('#message').html('Not Matching').css('color', 'red');
    $('#message').html('Nicht übereinstimmend').css('color', 'red')
    isMatch = false
  }

  // enable/disable update button
  if (isBest && isMatch) {
    $('#updateBtn').prop('disabled', false)
  } else {
    $('#updateBtn').prop('disabled', true)
  }
})