P
Phillip Ian
I have a textbox that I'm trying to limit to numeric entry (damn you
Microsoft for not including it in .NET!)
I've found sample code and come up with this as a solution:
<asp:TextBox id="fldQty" runat="server" CssClass="ThreePlaceInput"
MaxLength="3" Text='<%# DataBinder.Eval(Container, "DataItem.Qty") %>'
onKeyPress="javascript:return AllowOnlyNumbers();">
The Javascript looks like this:
<script language='javascript'>
<!--
function AllowOnlyNumbers() {
return ((event.keyCode >= 48) && (event.keyCode <= 57)) ||
(event.keyCode = 13);
}
-->
</script>
Now, for some reason, pressing a key that isn't accepted by the
function (non-numeric) is causing a postback. Obviously, this isn't
the intended result.
Also, this method doesn't seem to work at all in Firefox or Opera.
Anything I can do there?
Microsoft for not including it in .NET!)
I've found sample code and come up with this as a solution:
<asp:TextBox id="fldQty" runat="server" CssClass="ThreePlaceInput"
MaxLength="3" Text='<%# DataBinder.Eval(Container, "DataItem.Qty") %>'
onKeyPress="javascript:return AllowOnlyNumbers();">
The Javascript looks like this:
<script language='javascript'>
<!--
function AllowOnlyNumbers() {
return ((event.keyCode >= 48) && (event.keyCode <= 57)) ||
(event.keyCode = 13);
}
-->
</script>
Now, for some reason, pressing a key that isn't accepted by the
function (non-numeric) is causing a postback. Obviously, this isn't
the intended result.
Also, this method doesn't seem to work at all in Firefox or Opera.
Anything I can do there?