Is it possible to do something *after* something has finished in Javascript?
<p>I have a simple login page and I am trying to disable the username field, password field, and the submit button while I am authenticating, reenable them after if the password/username or both are wrong or simply login otherwise.</p>

<p>I am doing that using the following code:</p>

<pre><code>    // get the field values
    var usernameField = document.getElementById("username");
    var passwordField = document.getElementById("password");
    var submit = document.getElementById("submit");

    usernameField.disabled = "disabled";
    passwordField.disabled = "disabled";
    submit.disabled = "disabled";

    // Authentication code
</code></pre>

<p>and I want everything to be disabled before the authentication code starts. For now, what it does is that when I click on the submit button, it remains "stuck" for few seconds then either logs in or simply produces the error. But it never disables anything (I made sure this is not a css problem).</p>

<p>Let me know if more info is needed.</p>
