[jQuery] Programatically enabling ''submit' button in ASP.NET
I have the following aspx page
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.2.6.js" type="text/javascript"></
script>
</head>
<body>
<form id="form1" runat="server">
<div>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$(".checkedfield").blur(function() {
var allFilled = true;
$(".checkedfield").each(function() {
if (this.value == "") {
allFilled = false;
return;
};
});
if (allFilled) {
$("#btnSubmit").attr("disabled", false);
}
else
$("#btnSubmit").attr("disabled", true);
});
});
</script>
<asp:TextBox ID="tb1" class="checkedfield" runat="server"></
asp:TextBox>
<asp:TextBox ID="tb2" class="checkedfield" runat="server"></
asp:TextBox>
<asp:TextBox ID="tb3" class="checkedfield" runat="server"></
asp:TextBox>
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Button"
Enabled="false" />
</div>
</form>
</body>
</html>
It works. However, the button is enabled only when I tab out of the
last empty field (after entering something in it). It should be
enabled as soon as I start typing something. How?