how to use only integer values for NumericTextBox

2 Answers 19 Views
Input NumericTextBox
Emanuele
Top achievements
Rank 1
Veteran
Emanuele asked on 28 Jan 2025, 10:23 AM
Hi, I'm using in asp.net a NumericTextBox control, with a lower and upper limit value, but I don't know how to set that only integers are displayed, it seems that the limits and the maximum number of digits equal to 4 allow to limit the damage inserting years, but the '.' is displayed to separate the thousands

How do I avoid it? Thank you
<telerik:RadNumericTextBox runat="server" ID="txtFirstYear" RenderMode="Lightweight" MaxLength="4" MaxValue="2030" Visible="true" EmptyMessage="" MinValue="1998" CausesValidation="True" Culture="it-IT" DataType="System.Int32">
    <NumberFormat DecimalDigits="0"  />
</telerik:RadNumericTextBox>

2 Answers, 1 is accepted

Sort by
0
Accepted
Andrew
Top achievements
Rank 2
Iron
answered on 28 Jan 2025, 02:48 PM

Try using this in definition

 

NumberFormat-GroupSeparator=""

Emanuele
Top achievements
Rank 1
Veteran
commented on 29 Jan 2025, 10:38 AM

it works thanks
0
Andrew
Top achievements
Rank 2
Iron
answered on 28 Jan 2025, 10:34 AM

Hi,

I use the following definition and this works for me.

 

<telerik:RadNumericTextBox ID="tbSupplyAgreementDuration" Width="100%" ZIndex="100002" runat="server" MaxValue="999999" MinValue="0" NumberFormat-DecimalDigits="0" ClientEvents-OnKeyPress="keyPress">

</telerik:RadNumericTextBox>

 

function keyPress(sender, args) {
       var keyCharCode = args.get_domEvent().rawEvent.keyCode;

       if (keyCharCode == sender.get_numberFormat().DecimalSeparator.charCodeAt() || keyCharCode == sender.get_numberFormat().NegativeSign.charCodeAt()) {
               args.set_cancel(true);
       }
       if (keyCharCode == 13) {
               args.set_cancel(true);
       }
}
Emanuele
Top achievements
Rank 1
Veteran
commented on 28 Jan 2025, 11:00 AM

Thank you
but the problem does not arise when the separator character is typed, but when I for example enter '2000' and then the control formats the displayed text = '2.000'

Your scenario should not occur because I have set a minimum value to 1998 and a maximum of digits to 4 so if I enter '19.9' I get '1.998' but not '1998' which I would like
Tags
Input NumericTextBox
Asked by
Emanuele
Top achievements
Rank 1
Veteran
Answers by
Andrew
Top achievements
Rank 2
Iron
Share this question
or