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

RadNumericTextBox with range specifications: CustomValidator issue

2 Answers 162 Views
Input
This is a migrated thread and some comments may be shown as answers.
Dev LIPIX
Top achievements
Rank 1
Dev LIPIX asked on 17 Sep 2010, 04:47 PM
Please forgive me if this has already been addressed, but I believe I have found an issue with the RadNumericTextbox when specific ranges are involved.

The following is a simple mockup of the issue:
<html>
    <head>
        <script language="javascript" type="text/javascript">
            function RequireField(source, args) {
                if (args.Value == '') {
                    args.IsValid = false;
                }
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <telerik:RadScriptManager ID="ScriptManager" runat="server"></telerik:RadScriptManager>
            <b>Temp(°C):</b><telerik:RadNumericTextBox ID="Temp" Width="100px" NumberFormat-DecimalDigits="1" AllowOutOfRangeAutoCorrect="false"
                runat="server" MaxLength="5" MinValue="30" MaxValue="42">
            </telerik:RadNumericTextBox>
            <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="RequireField"
                ControlToValidate="Temp" ValidateEmptyText="true" ErrorMessage="Temperature is required and must be between 30 and 42"
                Display="None" ValidationGroup="SendValidationGroup"></asp:CustomValidator>
            <br /><br />
            <asp:Button ID="FormPost" runat="server" Text="Post Back" ValidationGroup="SendValidationGroup" />
 
            <asp:ValidationSummary EnableClientScript="true" ShowMessageBox="true" ShowSummary="false" ID="validationSummary" ValidationGroup="SendValidationGroup"
                runat="server" />
        </form>
    </body>
</html>

Values greater than 42 should not be allowed, however, when entering '400' the form submits and a value of '40' is sent to the custom validator's javascript function.

My assumption is that while typing 400, you obviously type 40 first and this value is then stored in the hidden field state somewhere.  However, this value is not cleared upon adding more zeros to '40'

If I clear the textbox, the hidden field state correctly passes an empty string to the validation function.

Please let me know if there is something simple that I am missing.

Regards,
Chris

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 20 Sep 2010, 09:41 AM
Hi Chris,

Thank you for reporting this bug. It will be fixed for the next release of RadControls. In the meantime, please use the following workaround. I have updated your Telerik points.

<%@ Page Language="C#" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
<head runat="server">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>RadControls</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
 
<b>Temp(°C):</b><telerik:RadNumericTextBox ID="Temp" Width="100px" NumberFormat-DecimalDigits="1" AllowOutOfRangeAutoCorrect="false"
    runat="server" MaxLength="5" MinValue="30" MaxValue="42">
</telerik:RadNumericTextBox>
<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="RequireField"
    ControlToValidate="Temp" ValidateEmptyText="true" ErrorMessage="Temperature is required and must be between 30 and 42"
    Display="None" ValidationGroup="SendValidationGroup"></asp:CustomValidator>
<br /><br />
<asp:Button ID="FormPost" runat="server" Text="Post Back" ValidationGroup="SendValidationGroup" />
  
<asp:ValidationSummary EnableClientScript="true" ShowMessageBox="true" ShowSummary="false" ID="validationSummary" ValidationGroup="SendValidationGroup"
    runat="server" />
 
<script type="text/javascript">
    function RequireField(source, args) {
        if (args.Value == '') {
            args.IsValid = false;
        }
    }
 
    function pageLoad()
    {
        if (typeof(Telerik) != "undefined" && typeof(Telerik.Web.UI.RadInputControl) != "undefined")
        {
            Telerik.Web.UI.RadInputControl.prototype._clearHiddenValue = function()
            {
                this._hiddenElement.value = "";
                this._setValidationField("");
            }
        }
    }
 
</script>
 
</form>
</body>
</html>


Sincerely yours,
Dimo
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Dev LIPIX
Top achievements
Rank 1
answered on 20 Sep 2010, 04:32 PM
Thank you for the workaround, it works just fine.

Regards,
Chris
Tags
Input
Asked by
Dev LIPIX
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Dev LIPIX
Top achievements
Rank 1
Share this question
or