Cancel Event when characters exceed maxlength or maxvalue

1 Answer 59 Views
NumericTextBox TextBox
Larry
Top achievements
Rank 2
Iron
Veteran
Iron
Larry asked on 17 Oct 2022, 06:07 PM | edited on 17 Oct 2022, 11:55 PM

Is there a way to cancel the keydown/keypress/keyup events to prevent non-digit characters from getting typed when characters in a TelerikTextBox? 

Also, I need a MaxLength set to 9 which the TelerikTextBox has but the TelerikNumericTextBox does not have.

I want to prevent non-digit characters, and I also want to disallow typing more than a specified number of characters.  The TelerikNumericTextBox only turns its border control red when exceeding a specified max value.  I want to prevent typing more than 'x' number of digits.

 

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 20 Oct 2022, 07:36 AM

Hi Larry,

The described scenario calls for a MaskedTextBox - it has built-in configuration settings for value length and allowed characters.

On a side note, the NumericTextBox has a Max parameter.

Regards,
Dimo
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Larry
Top achievements
Rank 2
Iron
Veteran
Iron
commented on 20 Oct 2022, 03:27 PM

Does the MaskedTextBox allow a variable number of characters or does it force a set number of characters?  I need max length to be 9 digits but I also need it to allow fewer digits
Dimo
Telerik team
commented on 21 Oct 2022, 12:44 PM

Tags
NumericTextBox TextBox
Asked by
Larry
Top achievements
Rank 2
Iron
Veteran
Iron
Answers by
Dimo
Telerik team
Share this question
or