disable submit button until form is filled
HTML
<form>
Username<br />
<input type="text" id="user_input" name="username" /><br />
Password<br />
<input type="password" id="pass_input" name="password" /><br />
<input type="submit" id="sign_in" value="submit" disabled="disabled" />
</form>
<div id="test">
</div>
JavaScript
(function() {
$('form > input').keyup(function() {
var empty = false;
$('form > input').each(function() {
if ($(this).val() == '') {
empty = true;
}
});
if (empty) {
$('#submit').attr('disabled', 'disabled');
} else {
$('#sign_in').removeAttr('disabled');
}
});
})()
/* instead of form we can use the IDs of certain fields only. In case not all fields are mandatory */