RadNumericTextBox - prevent input of decimal separator

2 posts, 0 answers
  1. JP
    JP avatar
    120 posts
    Member since:
    Aug 2011

    Posted 11 Sep 2013 Link to this post

    Hello,

    I want to use a RadNumericTextBox as input for integers. But there is still a problem: The user can still insert a decimal separator.
    How can I prevent this?
    This is the code:

    textBox = new RadNumericTextBox();
    textBox.ID = "NumTextBox";
    textBox.Type = NumericType.Number;
    textBox.DataType = typeof(int);
    textBox.NumberFormat.DecimalDigits = 0;
    textBox.ShowSpinButtons = true;

    What else must I set?

    Thanks!
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Sep 2013 Link to this post

    Hi JP,

    Please have a look into the following JavaScript I tried which works fine at my end.

    JavaScript:
    <script type="text/javascript">
        function OnKeyPress(sender, args) {
            var keycode = args.get_keyCode()
            if (keycode == 46 || keycode == 110) {
                args.set_cancel(true);
            }
        }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top