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

IE8 - RequiredFieldValidator - RadNumericTextBox

2 Answers 69 Views
Input
This is a migrated thread and some comments may be shown as answers.
Eazy
Top achievements
Rank 1
Eazy asked on 15 Jul 2010, 05:04 PM
Hey All,

I am running into a few issues when I try to use required field validators on the radnumerictext box. On the actual form that I was trying to develop I have several RadNumericTextBox controls that the user must at least touch in order for the form to be valid. To make it more convenient I have used JQuery (and tried straight javascript) to set the textbox's value to 0 if the user tabs out with out entering anything. The problem I am having is that the RequiredFieldValidator's do not seem to recognize that there is a number in the rad numeric text box unless I actually press 0. I have tried this with a regular asp.net text box and it works. It also works with the rad numeric text box in Firefox & Chrome. I have created a simplified asp .net page. The customAttribute="hiddenSection3" on the RadNumericTextBox and the hidden fields at the bottom are just there so the Utils.js doesn't throw an error. I have also tried it with out the customAttribute and the result is the same.

Thanks in advance


I have the following page: 
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="IETester.aspx.vb" Inherits="IETester" %>
 
<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
 
<%@ 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">
 
<head runat="server">
    <title>Untitled Page</title>
    <link type="text/css" rel="Stylesheet" href="css/chrome.css" />
    <script language="javascript" type="text/javascript" src="scripts/jquery-1.4.1.js"></script>
    <script language="javascript" type="text/javascript" src="scripts/jquery-1.4.1.min.js"></script>
    <script language="javascript" type="text/javascript" src="scripts/jquery-1.4.1-vsdoc.js"></script>
    <script language="javascript" type="text/javascript" src="scripts/Utils.js"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
     
        <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" customAttribute="hiddenSection3"  CssClass="numeric" NumberFormat-DecimalDigits="0">
        </telerik:RadNumericTextBox>
         
        <asp:Button ID="Button1" runat="server" Text="Button" />
         
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator" Display="Dynamic" ControlToValidate="RadNumericTextBox1"></asp:RequiredFieldValidator>
         
       <%-- <telerik:RadInputManager ID="RadInputManager1" runat="server">
             
            <telerik:NumericTextBoxSetting Type="Currency" BehaviorID="Setting2" Validation-IsRequired="true" EmptyMessage="Error" ErrorMessage="Error" Validation-ValidateOnEvent="All" >
                <TargetControls>
                    <telerik:TargetInput ControlID="RadNumericTextBox1" Enabled="true" />
                </TargetControls>
            </telerik:NumericTextBoxSetting>
           
        </telerik:RadInputManager>
        --%>
          <input type="hidden" id="hiddenIdentified" value="0" />
    <input type="hidden" id="hiddenPrevious" value="0" />
    <input type="hidden" id="hiddenTotal" value="0" />
    <input type="hidden" id="hiddenSection1" value="0" />
    <input type="hidden" id="hiddenSection2" value="0" />
    <input type="hidden" id="hiddenSection3" value="0" />
    </div>
    </form>
</body>
</html>

2 Answers, 1 is accepted

Sort by
0
Eazy
Top achievements
Rank 1
answered on 15 Jul 2010, 08:19 PM
Just wanted to update with more findings. Basically in IE when I set the value of the RadNumericTextBox with jquery/javascript and I can visually see it on the screen the .Text property is not being set at all. Even the code behind breaks saying that the input string is an incorrect format when I try to set an integer variable to the .Text property because it sees it as an empty string.
0
Eazy
Top achievements
Rank 1
answered on 16 Jul 2010, 03:24 PM
Ok here's the deal with this... when IE renders a RadNumericTextBox you get this in IE8:

<span class="RadInput RadInput_Default" id="RadNumericTextBox1_wrapper" style="white-space: nowrap;">
<input name="RadNumericTextBox1_text" class="riTextBox riEnabled numeric" id="RadNumericTextBox1_text" style="width: 125px;" type="text" customAttribute="hiddenSection3" jQuery1279226018531="2"/>
<input class="rdfd_" id="RadNumericTextBox1" style="padding-bottom: 0px; border-right-width: 0px; margin: -18px 0px 0px -1px; padding-left: 0px; width: 1px; padding-right: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 1px; visibility: hidden; overflow: hidden; border-left-width: 0px; padding-top: 0px;" type="text" Validators="[object]"/>
<input name="RadNumericTextBox1" class="rdfd_" id="RadNumericTextBox1_Value" style="padding-bottom: 0px; border-right-width: 0px; margin: -18px 0px 0px -1px; padding-left: 0px; width: 1px; padding-right: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 1px; visibility: hidden; overflow: hidden; border-left-width: 0px; padding-top: 0px;" type="text"/>
<input name="RadNumericTextBox1_ClientState" id="RadNumericTextBox1_ClientState" type="hidden"/>

If you use Javascript or JQuery to set value/text of the object "RadNumericTextBox1" you are actually setting the RadNumericTextBox1_text by default. IE does not handle this on the back end the same as the better browsers. Basically you will see if visually but you can not reference it because the the RadNumericTextBox1_Value is not being set. 

So basically to get around this for now I use do a replace('_text', '_Value'); and set both the objects. This however does not solve the problem with the RequiredFieldValidator because it is not validating against the RadNumericTextBox1_Value. I tried a few things at runtime to try and set the validator to the _Value but they all throw nasty errors. I am probably just going to use javascript to validate these.
Tags
Input
Asked by
Eazy
Top achievements
Rank 1
Answers by
Eazy
Top achievements
Rank 1
Share this question
or