NumericTextBox MinValue Question

3 posts, 1 answers
  1. Andrew
    Andrew avatar
    5 posts
    Member since:
    Jul 2012

    Posted 05 Oct 2012 Link to this post

    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. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 Oct 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andrew
    Andrew avatar
    5 posts
    Member since:
    Jul 2012

    Posted 15 Oct 2012 Link to this post

    We followed this pattern and it worked out for us very well.  Thank you for your help!

    Andrew
Back to Top