0

Hello,

I have a datagridview, where I can edit only 1 field, howerver, I cannot type "4,556" because I restricted it to only number, and if I type 0345, or "0,345" it will just save it as 345.

<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("AMOUNT") %>' BackColor = "#FF960C" MaxLength="4" onChange="intOnly(this);" onKeyUp="intOnly(this);" onKeyPress="intOnly(this);"></asp:TextBox>

Forgot the javascript:

<script language="javascript" type="text/javascript">
            function intOnly(i) {
                if (i.value.length > 0) {
                    i.value = i.value.replace(/[^\d]+/g, '');
                }
            }

My question is how can I make it for only numbers(including negative numbers) and be able to use comma?

Any help is appriciated!

Kind regards,

Edited by SQLpower

1
Contributor
1
Reply
11
Views
4 Years
Discussion Span
Last Post by SQLpower
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.