How to prevent user from entering non-digits to NumericTextBox on mobile devices?

2 posts, 1 answers
  1. Maxim
    Maxim avatar
    16 posts
    Member since:
    Jun 2008

    Posted 10 Sep 2014 Link to this post


    Currently user is able to enter any characters into NumericTextBox from mobile device (Android phone, for example). I've tested it on desktop browsers - an it works like expected. User cannot enter non-digits (IE, Chrome), event Chrome with mobile emulation works ok. But it does not work on mobile browser.

    You can see it event on demo site, if you open it on the phone or tablet.

    Is there any way to prevent user from entering invalid chars into the NumericTextBox?

    Thank you
  2. Answer
    Georgi Krustev
    Georgi Krustev avatar
    3747 posts

    Posted 12 Sep 2014 Link to this post

    Hello Maxim,

    The NumericTextBox widget validates user input using keydown and keypress events. Unfortunately, keypress is not triggered in mobile devices and most importantly keydown event cannot be prevented. Demo demonstrating this can be found here.

    This mobile browser limitation prevents the correct widget behavior and unfortunately I am out of ideas how this issue could be overcome. I would suggest you use a regular <input type="number" /> element in mobile devices.

    Georgi Krustev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top