jQuery validate email as I type
<p>The goal of the code below is, if the email address in the text field is valid, the submit button becomes active.</p>

<p>I've had this work using blur but it does not seem to work with keyboard events. 
Any ideas?</p>

<pre><code>$(document).ready(function(){                   
    // default values
    var email = $("#newsletter_email");
    var button = $("#subscribe");
    var a = $(email).val();
    var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;

    // disable submit
    $(button).attr("disabled", "disabled");
    $(button).css("background-color","#CCC");

    $(email).keydown(function(event) {
        if(filter.test(a)){
            button.attr("disabled", "enable");
            button.css("background-color","#663399");
        }
    });
});
</code></pre>
