0

I currently have a Log In screen and I disable the Login button until the user has entered their account # and last 4 of their SSN. It works fine so long as the user manually enters this information. However, I run into an issue if the user decides to use auto-complete to fill out the form because they must then tab off of the input field in order for it to register that the input has been entered and enable the Login button.

Is there a way I can automatically enable the LogIn button (assuming the data is correct) as soon as the user auto-completes everything? This is what I have so far:

    $("input[type=text], input[type=password]").on("keyup", enableLogIn);
    $("input[type=text], input[type=password]").bind("paste", enableLogIn);

    function enableLogIn() {
        if ($("#AccountNumber").val().length < 6 || $("#SocialSecurityNumber").val().length < 4) {
            $("#loginButton").attr("disabled", true);
        } else {
            $("#loginButton").attr("disabled", false);
        }
    }
The Vanilla Thrilla
  • 1,915
  • 10
  • 30
  • 49

1 Answers1

0

I think the edit event will be triggered when the field is modified, without waiting for tabbing out. Also notice that you can give multiple events to .on.

$("input[type=text], input[type=password]").on("keyup paste input", enableLogIn);

However, this is probably browser-dependent, I don't think older browsers have this event.

Barmar
  • 741,623
  • 53
  • 500
  • 612