You can easily hijack the validation mechanism callbacks using the validate method options. Here is an example (also put it on jsbin):
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
</head>
<body>
<script>
$(function() {
var button = $('#submit1');
function buttonHandler(validator) {
var errors = validator.numberOfInvalids();
if(errors === 0) {
button.removeAttr('disabled');
} else {
button.attr('disabled', 'disabled');
}
}
$('#form1').validate({
rules: {
text1: { required: true }
},
errorPlacement: function (error, element) {
error.insertAfter(element);
buttonHandler(this);
},
highlight: function (element, errorClass, validClass) {
$(element).addClass(errorClass);
$(element).removeClass(validClass);
buttonHandler(this);
},
unhighlight: function (element, errorClass, validClass) {
$(element).addClass(validClass);
$(element).removeClass(errorClass);
buttonHandler(this);
}
}).form(); // trigger validation
});
</script>
<form id="form1" action="#">
<input id="text1" name="text1" type="text" /><br/>
<input id="submit1" name="submit1" type="submit" value="Test" disabled="disabled" />
</form>
</body>
</html>
The key here is to trigger the validation before any user input (using the validator.form() method), so jquery.validate starts listening to the input events, and starts triggering the callbacks when the key (and other) events fire.