Ensuring passwords input in form match using javascript

I have coded an HTML form and need to ensure that a user inputs a password in the Password field and repeats the same password in the Confirm Password field. To ensure they are equal, I have used a javascript function to make it possible. Also, I have disabled the Register button, and need to ensure it is only enabled if and only if the values entered in the two password boxes are equal. Everything works fine, however, when the values entered are equal, the button remains disabled, and a warning that the passwords do not match still remains.

Below is the HTML code:

<div class="form-group mb-3">
                <label class="label" for="password">Password</label>
              <input id="password" type="password" class="form-control" placeholder="Password" name="passcode" required>
              <span toggle="#password" class="fa fa-fw fa-eye field-icon toggle-password"></span>
            </div>
            <div class="form-group mb-3">
                <label class="label" for="confirmPassword">Confirm Password</label>
              <input id="confirmPassword" type="password" class="form-control passcode" placeholder="Confirm Password" name="passCode" required onkeypress="checkConfirmation()">
              <span toggle="#confirmPassword" class="fa fa-fw fa-eye field-icon toggle-password"></span>
            </div>
            <span id="notEqualPassCode"></span>

Below is the javascript code for the checkConfirmation() function:

<script type="text/javascript">
function checkConfirmation(){
    var passcode = document.getElementById("password").value;
    var confirmPasscode = document.getElementById("confirmPassword").value;
    let btnSubmit = document.querySelector(".submit");
    btnSubmit.disabled = true;

    if (passcode != confirmPasscode){
        btnSubmit.disabled = true;
        document.getElementById("notEqualPassCode").innerHTML = '<i class="fa fa-fw fa-exclamation-triangle"></i>Passwords do not match!';
    } else {
        btnSubmit.disabled = false;
        document.getElementById("notEqualPasscode").innerHTML = '';
    }
}

Please someone tell me what could be wrong.