i have textbox in repeater and i want to validate it to accept numbers only i have code like this
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table border="1" width="100%">
<tr>
<th>id</th>
<th align=left>Room Categories</th>
<th>single</th>
<th>Double</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="5%">
<asp:Label ID="Label3" runat="server" Text= '<%# Container.DataItem("packageid")%>' /></td>
<td> <asp:CheckBox ID="chk_packages" AutoPostBack=true runat="server" Text = <%#Container.DataItem("package_name")%> /> </td>
<td><%#Container.DataItem("single_rate")%><asp:CheckBox AutoPostBack=true ID="single" Enabled=false runat="server" />Number of Rooms<asp:TextBox ID="txt_single" OnTextChanged="NumberOnly();" Enabled=false width="10px" MaxLength="2" runat="server"></asp:TextBox></td>
<td><%#Container.DataItem("double_rate")%><asp:CheckBox AutoPostBack=true ID="Double" Enabled=false runat="server" />Number of Rooms<asp:TextBox ID="txt_double" Enabled =false width="10px" MaxLength="2" runat="server"></asp:TextBox></td>
<td></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<script type="text/javascript">
function NumberOnly() {
var t = window.event.keyCode;
if (t >= 48 & t <= 57)
return;
window.event.keyCode = 0;
}
</script>
it gives error like this
Line 777:<td><%#Container.DataItem("single_rate")%><asp:CheckBox AutoPostBack=true ID="single" Enabled=false runat="server" />Number of Rooms<asp:TextBox ID="txt_single" OnTextChanged="NumberOnly();" Enabled=false width="10px" MaxLength="2" runat="server"></asp:TextBox></td>
Line 778:
Line 779:<td><%#Container.DataItem("double_rate")%><asp:CheckBox AutoPostBack=true ID="Double" Enabled=false runat="server" />Number of Rooms<asp:TextBox ID="txt_double" Enabled =false width="10px" MaxLength="2" runat="server"></asp:TextBox></td>