This is a migrated thread and some comments may be shown as answers.

Issue with Numeric TextBox

3 Answers 145 Views
Input
This is a migrated thread and some comments may be shown as answers.
Dorababu
Top achievements
Rank 1
Dorababu asked on 03 Oct 2012, 12:09 PM
Hi all when I enter values as follows 1234567891234567891 in Numeric Textbox I am getting some thing like as follows when I leave the textbox 70368744177664 what should I do in-order to accepts a long digit in Numeric Textbox.

Also when I enter some thing like 1222 it is displaying as 1,222.00 what should I do in-order to display as it is as the entered value

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Oct 2012, 06:04 AM
Hi Dorababu,

You can set Maxvalue property of RadNumericTextbox to accept long digits.But RadNumericTextxbox control does not support maximum or minimum value more/less than +/- 2^46. Setting the Maxvalue property  more than 2^46 may cause abnormalities in the behavior. You can use the RadTextBox control with RegExp to accept values greater than 2^46. Try the following code to avoid rounding and grouping in RadNumericTextbox.

ASPX:
<telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" MaxValue="12345678912345678" AllowOutOfRangeAutoCorrect="false" >
  <NumberFormat AllowRounding="false" GroupSeparator="" />
</telerik:RadNumericTextBox>

Thanks,
Princy.
0
Dorababu
Top achievements
Rank 1
answered on 04 Oct 2012, 08:44 AM
I can't fix max value as per given why because user can enter any with a max length of 19..
0
Princy
Top achievements
Rank 2
answered on 05 Oct 2012, 04:52 AM
Hi DoraBabu,

Try the following code to achieve your scenario.

ASPX:
<telerik:RadTextBox ClientEvents-OnKeyPress="OnKeyPress" ID="RadTextBox1" runat="server"></telerik:RadTextBox>

JS:
<script type="text/javascript">
    function OnKeyPress(sender, args)
    {
        var reg = new RegExp("[0-9]{1}");
        var pressed = args.get_keyCharacter();
        var key = args._keyCode;
        if (((36 < key) && (40 > key)) || (key == 8) || (key == 46))
        {
            return;
        }
        if (!pressed.match(reg))
        {
            args.set_cancel(true);
        }
    }
</script>

Hope this helps.

Thanks,
Princy.
Tags
Input
Asked by
Dorababu
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Dorababu
Top achievements
Rank 1
Share this question
or