RequiredFieldValidator for RadTextBox not firing

3 posts, 1 answers
  1. Lee
    Lee avatar
    9 posts
    Member since:
    Jul 2012

    Posted 12 Jul 2012 Link to this post

    Hi!

    I'm really confused as to why my RequiredFieldValidators are not working.  Basically I have .aspx page that is being used as a RadWindow-- A kind of edit dialog.  On that page is a User Control (.ascx) that has a panel with my RadTextBoxes and submit button.  I'm trying to setup 
    RequiredFieldValidators  on those textboxes but cannot figure out why they are not firing when I click the button.  Here is the panel in question. What am I doing wrong?  Thanks!

    <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="All"
        Skin="Web20"></telerik:RadFormDecorator>
    <asp:Panel ID="StatesEditPanel" CssClass="maintext" BackColor="#FFFFFF" runat="server">
        <asp:Label ID="lblStatesHeader" runat="server" Font-Bold="True"></asp:Label><br />
        <table id="StatesTable" border="0" cellspacing="1" cellpadding="2" width="100%">
            <tr>
                <td style="font-weight: bold; text-align: right; vertical-align: middle;">
                    State Abbreviation:
                </td>
                <td style="text-align: left;">
                    <telerik:RadTextBox ID="rtxtStateAbbrev" runat="server" Width="10%" EmptyMessage=""
                        Skin="Web20" Font-Size="9pt" BackColor="#fdf5e6" MaxLength="2" SelectionOnFocus="SelectAll"
                        ValidationGroup="lookupedit" />
                    <asp:RequiredFieldValidator ID="StateAbbrevRequiredFieldValidator" runat="server"
                        ControlToValidate="rtxtStateAbbrev" Display="Dynamic" InitialValue=" ---" EnableClientScript="true"
                        ErrorMessage="You must enter a State Abbreviation!" Font-Size="7pt" ForeColor="Red"
                        ValidationGroup="lookupedit"
                        Font-Bold="true" />
                </td>
            </tr>
            <tr>
                <td style="font-weight: bold; text-align: right; vertical-align: middle;">
                    Description:
                </td>
                <td style="text-align: left;">
                  <telerik:RadTextBox ID="rtxtStateName" runat="server" Width="40%"
                        Skin="Web20" Font-Size="9pt" BackColor="#fdf5e6" MaxLength="10"
                        ValidationGroup="lookupedit" />
                    <asp:RequiredFieldValidator ID="StateDescriptionRequiredFieldValidator" runat="server"
                        ControlToValidate="rtxtStateName" EnableClientScript="true" Display="Dynamic"
                        InitialValue=" ---" Text="You must enter a Description!" Font-Size="7pt"
                        ForeColor="Red" ValidationGroup="lookupedit" Font-Bold="true" />
                </td>
            </tr>
            <tr>
                <td style="font-weight: bold; text-align: right; vertical-align: middle;" class="style1">
                    Tax Rate:
                </td>
                <td style="text-align: left;" class="style1">
                    <telerik:RadTextBox ID="rtxtStateTaxRate" runat="server" Width="20%" EmptyMessage=""
                        Skin="Web20" Font-Size="9pt" BackColor="#fdf5e6" MaxLength="10" SelectionOnFocus="SelectAll"
                        CausesValidation="True" ValidationGroup="lookupedit" />
                    <asp:RequiredFieldValidator ID="StateTaxRateRequiredFieldValidator" runat="server"
                        ControlToValidate="rtxtStateTaxRate" Display="Dynamic" InitialValue=" ---" EnableClientScript="true"
                        ErrorMessage="<br />You must enter a State Tax Rate!" Font-Size="7pt" ForeColor="Red"
                        Font-Bold="true" ValidationGroup="lookupedit" />
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center;">
                    <asp:Button ID="btnStatesSave" runat="server" Font-Bold="True" Text="Save" CausesValidation="true"
                        Width="80px" ValidationGroup="lookupedit" /> 
                    <asp:Button ID="btnStatesDelete" runat="server" Font-Bold="True" Text="Delete" CausesValidation="true"
                        Width="80px" />
                </td>
            </tr>
        </table>
    </asp:Panel>





  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Jul 2012 Link to this post

    Hi Lee,

    I am able to make the required field validator working when I set the text as "---" .It is the expected behaviour since you are setting the initial value.
    And you are setting maxlength to 2 along with initial value "---" for "rtxtStateAbbrev". Which will never causes validation failure. Because Validation fails only if the value of the associated input control matches this InitialValue upon losing focus.

    Hope this helps.

    Thanks,
    Princy.
  3. Lee
    Lee avatar
    9 posts
    Member since:
    Jul 2012

    Posted 13 Jul 2012 Link to this post

    Thank you!!!
Back to Top