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

NumericTextBox MinValue Question

2 Answers 67 Views
Input
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 05 Oct 2012, 03:30 PM

Hi,

My team is having an issue with the NumericTextBox and the developer currently having the issue asked that I post his question in the forum on his behalf since he is having a technical issue with his workstation that is preventing him from posting himself.

"Using the NumericTextbox, I am seeing behavior that is not the way that I want or expect. I have a MinValue="0" and a MaxValue="100". I have a InvalidStyleDuration="2000000".

When the user enters -1, the textbox border turns red and there is an invalid icon in the textbox. What is happening that I don't want is that the -1 value that was entered is replaced by the MinValue, 0. How can I get the entered value, -1, to remain in the textbox?"

Thanks,

Andrew

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 09 Oct 2012, 04:34 AM
Hi Andrew,

One suggestion is that you can handle the validation in OnValueChanged event of RadNumericTextBox without setting MinValue and MaxValue Properties as follows.

ASPX:
<telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" ClientEvents-OnValueChanged="OnValueChanged"></telerik:RadNumericTextBox>

JS:
<script type="text/javascript">
 function OnValueChanged(sender, args)
 {
  if (sender.get_value() > 100 || sender.get_value() < 0)
  {
   setTimeout(function () { sender.addCssClass("riError"); }, 20);
  }
 }
</script>

Hope this helps.

Thanks,
Princy.
0
Andrew
Top achievements
Rank 1
answered on 15 Oct 2012, 10:17 PM
We followed this pattern and it worked out for us very well.  Thank you for your help!

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