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
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.
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>
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
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
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.
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
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
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