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,

You can close the thread, solved it. Cheers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.