RadNumeric -ASP

11 posts, 0 answers
  1. Eva
    Eva avatar
    65 posts
    Member since:
    Oct 2007

    Posted 08 Jan 2009 Link to this post

    Hi All,

    I need a RadNumeric TextBox ,which will accept only full number like 0,1,2....  .It won't accept negative number , decimal point ..
    How do i customize this behavior.

    Also i want to apply validation similar to RadDateInput ,shown in this demo
    http://demos.telerik.com/aspnet-ajax/Input/Examples/RadDateInput/FirstLook/DefaultCS.aspx

    Can anybody help me ASP.

    Thanks in Advance.
    Eva
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 09 Jan 2009 Link to this post

    Hi Eva,

    Try setting the DecimalDigits attribute of the RadNumericTextBox to zero  for preventing the decimal point. For preventing negative value set MinValue to zero.

    ASPX:
    telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" MinValue="0" Type="Number" > 
              <NumberFormat  DecimalDigits="0"/> 
            </telerik:RadNumericTextBox> 

    You can also refer the following demo link for getting details on setting Validation with RadNumericTextBox.
    Validation

    Shinu

  3. Eva
    Eva avatar
    65 posts
    Member since:
    Oct 2007

    Posted 09 Jan 2009 Link to this post

    Hi Shinu,

    Thanks for your reply.

    I tried your code, it's still accepting decimal values,like 23.6777.  I don't want user to enter decimal points,is there any way to do that.

    I want to show the validation for RadNumericTextBox similar to  RadDateInput  . Like allow the user to enter any information ,but while leaving it should pop up with red color error icon ,with the user information. Is it clear.

    I would like to explain in visualy but unfortunately there is no option to upload in this forums.

    Please let me know ASP.

    Thanks in advance.
    Eva
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Jan 2009 Link to this post

    Hi Eva,

    If you need to prevent user from entering the decimal point in the numeric textbox you can try the following approach.

    ASPX:
     <ClientEvents  OnBlur="Blur" OnKeyPress="KeyPress" /> 


    JS:
    <script type="text/javascript" language="javascript"
     
    function KeyPress(sender, eventArgs) 
     var c = eventArgs; 
     if (c.get_keyCharacter()=='.'
      { 
       
          eventArgs.set_cancel(true); 
       } 
     
    </script> 


    Princy
  5. Eva
    Eva avatar
    65 posts
    Member since:
    Oct 2007

    Posted 14 Jan 2009 Link to this post


    Is there any workaround to show the validation for RadNumericTextBox similar to  RadDateInput  . Like allow the user to enter any information ,but while leaving it should pop up with red color error icon inside textbox ,with the user information.
    Is it clear.

  6. Steve Y
    Steve Y avatar
    115 posts
    Member since:
    Sep 2008

    Posted 14 Jan 2009 Link to this post

    Check out RadInputManager to see if it'll work for you.

    You can find the demos here. http://demos.telerik.com/aspnet-ajax/Input/Examples/RadInputManager/FirstLook/DefaultCS.aspx

    Regards, Steve
  7. Eva
    Eva avatar
    65 posts
    Member since:
    Oct 2007

    Posted 15 Jan 2009 Link to this post

    I tried this demo.But it doesn't work.

    My question is i need to act RadNumeric Textbox validation simillar to raddateinput validation (like user can enter any information ,but while leaving it should pop up with red color error icon inside textbox ,with the user information)

    Is it possible.

    Thanks in Advance.
    Eva
  8. Steve Y
    Steve Y avatar
    115 posts
    Member since:
    Sep 2008

    Posted 15 Jan 2009 Link to this post

    Yep - you're right. It doesn't act the way you want.

    It stops you from entering anything other than numeric data plus formatting (.,-etc). If you enter a number higher than max, it will substitute max, and if you put in anything lower than min, it'll substitute min.

    I think I would prefer it to display an error message and allow the user to go and fix it vs. change the data input and hope it's what the user wants. This would then give it a level of consistency with the way regex, masked and required validation works.

    Anyone else have any thoughts on this? Telerik?

    Thanks, Steve
  9. Eva
    Eva avatar
    65 posts
    Member since:
    Oct 2007

    Posted 15 Jan 2009 Link to this post



    Thanks steve , you are correct , even i am looking for simillar bevaviour. 
    It will be good user can see what they are entering simillar to raddateinput validation.

    Telerik ?




  10. Dimo
    Admin
    Dimo avatar
    8457 posts

    Posted 16 Jan 2009 Link to this post

    Hello Eva,

    We will implement the requested behavior in a future version of the control. Thanks for the suggestion.

    In the meantime, you can use something like this:


    <%@ Page Language="C#" %> 
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
     
    <script runat="server"
     
        public double NumericMinValue; 
        public double NumericMaxValue; 
         
        protected void Page_Load(object sender, EventArgs e) 
        { 
            NumericMinValue = RadNumericTextBox1.MinValue; 
            NumericMaxValue = RadNumericTextBox1.MaxValue; 
     
            RadNumericTextBox1.MinValue = Double.MinValue; 
            RadNumericTextBox1.MaxValue = Double.MaxValue; 
        } 
         
    </script> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml"
    <head runat="server"
    <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
    <title>RadControls for ASP.NET AJAX</title> 
    </head> 
    <body> 
    <form id="form1" runat="server"
    <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
     
    <p> 
    NumericMinValue: <%= NumericMinValue %> 
    <br /> 
    NumericMaxValue: <%= NumericMaxValue %> 
    </p> 
     
    <p>Enter an invalid value:</p> 
     
    <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" MinValue="10" MaxValue="20"
        <ClientEvents OnValueChanged="ValueChanged" /> 
    </telerik:RadNumericTextBox> 
     
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
    <script type="text/javascript"
     
    var numericMinValue = <%= NumericMinValue %>
    var numericMaxValue = <%= NumericMaxValue %>
     
    function ValueChanged(sender, args) 
        if (args.get_newValue() < numericMinValue || args.get_newValue() > numericMaxValue) 
        { 
            sender._invalid = true
        } 
        else 
        { 
            sender._invalid = false
        } 
         
        sender.updateCssClass(); 
     
    </script> 
    </telerik:RadCodeBlock>  
     
    </form> 
    </body> 
    </html> 
     


    Sincerely yours,
    Dimo
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  11. Dimo
    Admin
    Dimo avatar
    8457 posts

    Posted 03 Jul 2009 Link to this post

    Hello,

    I would like to inform you that we have just implemented the requested functionality, namely - if you enter a number, which is beyond the range of valid values, RadNumericTextBox will keep showing the value together with its InvalidStyle (the control will have no value). The behavior of the textbox will be controlled via a property and the default behavior will be the same as until present.

    The feature will be included in the next service pack and nightly builds.

    All the best,
    Dimo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top