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

RadNumericTextBox causes validation with its own empty message

9 Answers 350 Views
Input
This is a migrated thread and some comments may be shown as answers.
Hasitha
Top achievements
Rank 1
Hasitha asked on 06 Dec 2013, 07:18 PM
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

 

9 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Dec 2013, 03:23 AM
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.
0
Hasitha
Top achievements
Rank 1
answered on 09 Dec 2013, 02:27 PM
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>




0
Viktor Tachev
Telerik team
answered on 12 Dec 2013, 12:51 PM
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.
0
Maria Ilieva
Telerik team
answered on 12 Dec 2013, 01:18 PM
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.
0
Robert
Top achievements
Rank 1
answered on 23 Sep 2015, 09:17 PM

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.

0
Viktor Tachev
Telerik team
answered on 24 Sep 2015, 12:30 PM
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
0
Robert
Top achievements
Rank 1
answered on 24 Sep 2015, 02:02 PM
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.
0
Viktor Tachev
Telerik team
answered on 28 Sep 2015, 01:24 PM
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
0
Qing
Top achievements
Rank 1
answered on 29 Jan 2020, 10:57 AM

Dear Viktor Tachev ,

         Now I would like to ask one question. How can i validate the only numeric character when user type in the RadCombo Box. I make AllowCustomText="true" in my RadCombo Box. I have no idea and got headache. Please kindly help me. Thanks.

 

best regards,

Qing Qing

Tags
Input
Asked by
Hasitha
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Hasitha
Top achievements
Rank 1
Viktor Tachev
Telerik team
Maria Ilieva
Telerik team
Robert
Top achievements
Rank 1
Qing
Top achievements
Rank 1
Share this question
or