I'm attempting to disable a submit button untill the user has filled out the input fields in the form.
I found THIS thread here which had a really good answer. I'm having just a little problem getting the submit button the re-enable when the fields are filled out.
Can someone please take a look at this function and help me figure out what I'm missing? Any help would be greatly appreciated :D Thank you.
Heres a Fiddle also
$(document).ready(function() {
var $submit = $("input[type=submit]");
if ( $("input:empty").length > 0 ) {
$submit.attr("disabled","disabled");
} else {
$submit.removeAttr("disabled");
}
});
<form method="POST" action="<%=request.ServerVariables("SCRIPT_NAME")%>">
User Name: <input name="Username" type="text" size="14" maxlength="14" /><br />
Password: <input name="last_name" type="password" size="14" maxlength="14"><br />
<input type="submit" value="Login" name="Submit" id="loggy">
</form>