registration.js 1.04 KB
Newer Older
Rosanny Sihombing's avatar
Rosanny Sihombing committed
1
2
let isEmailValid = false
let isPasswordValid = false
3
4

// check if email already exist
Rosanny Sihombing's avatar
Rosanny Sihombing committed
5
6
7
8
9
10
11
12
13
14
15
16
$('#inputEmail').change(function () {
  const email = $('#inputEmail').val()
  $.get('email/' + email, function (data) {
    $('#emailWarning').empty()
    isEmailValid = data
    if (!isEmailValid) {
      $('#emailWarning').html('Mit dieser E-Mail-Adresse existiert bereits ein Benutzerkonto in unserem Transferportal.')
    }
    switchSubmitButton()
  })
    .fail(function () {
      console.log('cannot check email')
17
    })
Rosanny Sihombing's avatar
Rosanny Sihombing committed
18
})
19
20
21

// check password
$('#inputPassword').on('keyup', function () {
Rosanny Sihombing's avatar
Rosanny Sihombing committed
22
23
24
25
26
27
28
29
  isPasswordValid = checkPasswordReq($('#inputPassword').val())
  $('#passwordWarning').empty()
  if (!isPasswordValid) {
    // $('#passwordWarning').html('Must be at least 8 characters')
    $('#passwordWarning').html('Das Passwort muss mindestens 8 Zeichen haben')
  }
  switchSubmitButton()
})
30

Rosanny Sihombing's avatar
Rosanny Sihombing committed
31
32
33
34
35
36
37
function switchSubmitButton () {
  if (isEmailValid && isPasswordValid) {
    $('#submitBtn').prop('disabled', false)
  } else {
    $('#submitBtn').prop('disabled', true)
  }
}