extends layout

block main
  form(method='post')
    input(type='hidden',name='_csrf',value=csrfToken)
    p Enter your desired username:
    input(type='text',name='username')
    p Enter your desired password:
    input#password(type='password',name='password')
    input#password2(type='password')
    p#passwarn
    label
      input(type="checkbox",name="authenticate",checked)
      | Log into my new account when I submit this form
    input(type='submit')
  script.
    var pwInput = document.getElementById('password')
    var pw2Input = document.getElementById('password2')
    var pWarn = document.getElementById('passwarn')
    function checkAndWarn(){
      if (pwInput.value == pw2Input.value) {
        pWarn.textContent = 'Passwords match';
        pWarn.style.backgroundColor = '#afa';
      } else {
        pWarn.textContent = 'Passwords do not match';
        pWarn.style.backgroundColor = '#faa';
      }
    }
    pwInput.addEventListener('keydown', checkAndWarn);
    pw2Input.addEventListener('keydown', checkAndWarn);

extends layout

block main
  form(method='post')
    input(type='hidden',name='_csrf',value=csrfToken)
    p Enter your desired username:
    input(type='text',name='username')
    p Enter your desired password:
    input#password(type='password',name='password')
    input#password2(type='password')
    p#passwarn
    label
      input(type="checkbox",name="authenticate",checked)
      | Log into my new account when I submit this form
    input(type='submit')
  script.
    var pwInput = document.getElementById('password')
    var pw2Input = document.getElementById('password2')
    var pWarn = document.getElementById('passwarn')
    function checkAndWarn(){
      if (pwInput.value == pw2Input.value) {
        pWarn.textContent = 'Passwords match';
        pWarn.style.backgroundColor = '#afa';
      } else {
        pWarn.textContent = 'Passwords do not match';
        pWarn.style.backgroundColor = '#faa';
      }
    }
    pwInput.addEventListener('keyup', checkAndWarn);
    pw2Input.addEventListener('keyup', checkAndWarn);

Use keyup for password matching
Use keyup for password matching
