RadNumericTextBox causes validation with its own empty message

9 posts, 0 answers
  1. Hasitha
    Hasitha avatar
    2 posts
    Member since:
    Mar 2013

    Posted 06 Dec 2013 Link to this post

    Hi,

    I have a RadNumericTextBox with an empty message "VEHICLE NUMBER". Upon insertion of vehicle number and other fields user can click on the Update button which causes a post back. The first time the page loads the update button doesn't validate input fields like the vehicle number and causes a post back which is the intended functionality.

    However, when I type some number and delete it at the same time the Update button validates the  Vehicle Number RadNumericTextBox.
    If I remove the empty message or put a numeric value to the empty massage then the update button works as usual.

    It seems that the RadNumericTextBox conflicts with its own EmptyMessage which is not necessarily be a number.

    How to avoid this?

    Thanks

     
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 08 Dec 2013 Link to this post

    Hi Hasitha,

    Please have a look into the following  sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" EmptyMessage="VEHICLE NUMBER">
    </telerik:RadNumericTextBox>
    <telerik:RadButton ID="RadButton1" runat="server" Text="Validate" OnClick="RadButton1_Click">
    </telerik:RadButton>

    C#:
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        if (RadNumericTextBox1.Text == "")
        {
            Response.Write("<script>alert('Enter vehicle number');</script>");
        }
        else
        {
            Response.Write("<script>alert('success');</script>");
        }
    }

    Let me know if you have any concern.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hasitha
    Hasitha avatar
    2 posts
    Member since:
    Mar 2013

    Posted 09 Dec 2013 Link to this post

    Hi Shinu,

    Thanks for your reply.

    Unfortunately I am not sure which version of Telerik controls you are using and it might have been fixed in the newer version. I have mentioned below some details about mine and also the code which I use to re-produce the strange behavior. Surprisingly when I increase the MaxLength to higher value(20) it works.

    Telerik Version : 2012.2.912.35
    .NET Version : 3.5
    IE: 10

    How to re-produce: Type something in the textbox. Delete the text and then Update.
    -----------------------------------------------------

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits=".WebForm1" %>

    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

    <!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">

    <title></title>

    </head>

    <body>

    <form id="form1" runat="server">

    <div>

    <asp:ScriptManager ID="ScriptManager1" runat="server">

    </asp:ScriptManager>

    <telerik:RadNumericTextBox runat="server" ID="txtVehicleNumber" EmptyMessage="VEHICLE NUMBER" EmptyMessageStyle-Font-Italic="true"

    Width="120px" MaxValue="999999" MinValue="0" MaxLength="6"

    Type="Number">

    <NumberFormat DecimalDigits="0" GroupSeparator="" />

    </telerik:RadNumericTextBox>

    <br />

    <asp:Button ID="Update" runat="server" Text="Button" />

    </div>

    </form>

    </body>

    </html>




  5. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 12 Dec 2013 Link to this post

    Hello Hasitha,

    The strange behavior is caused by using MaxLength property with numeric input. This property is generally used to limit the number of characters that could be entered by the user. Moreover this behavior should be observed only in IE10 due to the way validation is implemented in this browser version.

    When there is a numeric input more appropriate way to set limits to the entered values would be via MinValue and MaxValue. When using these two properties MaxLength is not needed, you could remove it and the text box should be validated as expected.

    Regards,
    Viktor Tachev
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  6. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 12 Dec 2013 Link to this post

    Hello Hasitha,

    The strange behavior is caused by using MaxLength property with numeric input. This property is generally used to limit the number of characters that could be entered by the user. Moreover this behavior should be observed only in IE10 due to the way validation is implemented in this browser version.

    When there is a numeric input more appropriate way to set limits to the entered values would be via MinValue and MaxValue. When using these two properties MaxLength is not needed, you could remove it and the text box should be validated as expected.

    Regards,
    Maria Ilieva
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  7. Robert
    Robert avatar
    2 posts
    Member since:
    Sep 2015

    Posted 23 Sep 2015 Link to this post

    Unfortunately, the problem is that RadComboBox has this issue too.  The MaxLength attribute is limiting the EmptyMessage attribute.  This is only happening for me with IE 11.  There are no error messages.  It just won't process the field.  If you shorten the message to less then the maxlength setting then it will update the field.  With my field needing to be limited to 5 characters, it makes it impossible to use the EmptyMessage attribute.

    So it seems RadNumericTextBox and RadComboBox has this issue.  How many others are there?  Please help!

    Thanks.

  8. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 24 Sep 2015 Link to this post

    Hello Robert,

    The MaxLength property is available for RadNumericTextBox because it is inherited from the RadInputControl class. Using MaxLength with RadNumericTextBox does not make sense as the input accepts only numeric values.

    If you would like to limit the input for RadNumericTextBox you should set the MaxValue and MinValue properties.

    As for the RadComboBox, I tested the behavior and the MaxLength property does not affect the empty message. The markup I tested with is available below.

    <telerik:RadComboBox runat="server" ID="RadComboBox1" MaxLength="6" EmptyMessage="test message" >
        <Items>
            <telerik:RadComboBoxItem Text="item 1" />
            <telerik:RadComboBoxItem Text="item 2" />
            <telerik:RadComboBoxItem Text="item 3" />
        </Items>
    </telerik:RadComboBox>


    With that said, would you elaborate in more detail why do you need to have MaxLength for the RadComboBox control? Please describe what is the scenario that you would like to implement.


    On a side note, ensure that you are using the latest version of the controls. The current released version is 2015.2.826.


    Regards,
    Viktor Tachev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  9. Robert
    Robert avatar
    2 posts
    Member since:
    Sep 2015

    Posted 24 Sep 2015 in reply to Viktor Tachev Link to this post

    Ok, it looks like we're on an older version.  So we might not have a bug fix or two from the past.  Until I figure out our version licensing, I'll be using a smaller EmptyMessage string to get past our issue.  The MaxLength field is necessary for us, because anything greater generates an error.  Thanks for your fast response.
  10. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 28 Sep 2015 Link to this post

    Hello Robert,

    I am glad that you have worked around the issue for now. Let us know how the latest release is working for you once you get a change to test it.

    Regards,
    Viktor Tachev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017