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

Don't allow negative value in RadNumericTextBox

1 Answer 452 Views
Input
This is a migrated thread and some comments may be shown as answers.
Nileshkumar
Top achievements
Rank 1
Nileshkumar asked on 09 Jul 2013, 07:13 AM
Hi,
I have widely used RadNumericTextBox in my application. I want to restrict the user to enter negative value in the RadNumericTextBox without set to MinValue = 0. We can set MinValue=0 but in this case also user can enter the negative value however it will be set to 0 by default.
But i don't want to allow the user to enter negative values in entire application. Can anyone have solution to solve this issue ?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Jul 2013, 10:47 AM
Hi Nileshkumar,

If you want to restrict the user from entering the minus (-) character into the RadNumericTextBox, try attaching the following JavaScript code to the OnKeyPress Client event of the control.

JavaScript:
<script type="text/javascript">
    function keypress(sender, args) {
        if ((args.get_keyCode() == 109) || (args.get_keyCode() == 45)) {
            args.set_cancel(true);
        }
    }
</script>

Thanks,
Princy.

Tags
Input
Asked by
Nileshkumar
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or