Ajax call breaks RadMaskedTextBox with RegularExpressionValidator

4 posts, 0 answers
  1. John
    John avatar
    22 posts
    Member since:
    Apr 2012

    Posted 03 Dec 2013 Link to this post

    I have a RadMaskedTextBox with a RegularExpressionValidator. I want to allow users to enter a U.S. style phone number in the correct format, but the phone number field is not required. When the page initially loads, the functionality works as expected; the field only fails validation if the user provided input, and that input is invalid. However, if the page fires any Ajax (RadAjaxManager), the validator fires (and fails), even if no input is provided in this field on submit.  It will work is proper input is provided, essentially making it the field behave as if a RequiredFieldValidator was placed on it.

    <telerik:RadMaskedTextBox  ID="txtPhone" runat="server"  Mask="(###) ###-####" TabIndex="29" Width="175px" meta:resourcekey="txtPhoneResource1" ViewStateMode="Enabled" DisplayMask="(###) ###-####" LabelWidth="70px" Rows="1"></telerik:RadMaskedTextBox>
     <asp:RegularExpressionValidator ID="txtPhoneRegularExpressionValidator"
        runat="server" ErrorMessage="Format is (###) ###-####" ControlToValidate="txtPhone"
        ValidationExpression="\(\d{3}\)\s\d{3}-\d{4}" SetFocusOnError="True"></asp:RegularExpressionValidator>
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Dec 2013 Link to this post

    Hi John,

    Unfortunately I couldn't replicate the issue. Please have a look into the following code snippet which works fine at my end.

    ASPX:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadButton1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="txtPhone" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadMaskedTextBox ID="txtPhone" runat="server" Mask="(###) ###-####" TabIndex="29"
        Width="175px" meta:resourcekey="txtPhoneResource1" ViewStateMode="Enabled" DisplayMask="(###) ###-####"
        LabelWidth="70px" Rows="1">
    </telerik:RadMaskedTextBox>
    <asp:RegularExpressionValidator ID="txtPhoneRegularExpressionValidator" runat="server"
        ErrorMessage="Format is (###) ###-####" ControlToValidate="txtPhone" ValidationExpression="\(\d{3}\)\s\d{3}-\d{4}"
        SetFocusOnError="True"></asp:RegularExpressionValidator>
    <telerik:RadButton ID="RadButton1" runat="server" Text="Submit">
    </telerik:RadButton>

    Please provide your complete code if it doesn't help you.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. John
    John avatar
    22 posts
    Member since:
    Apr 2012

    Posted 09 Dec 2013 Link to this post

    What makes this issue weirder is that it is not an initiator or a target of a Ajax event at all. It is not in any panel updated by an Ajax event.

    MasterPage
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
              <ClientEvents OnRequestStart="doLoadingPanel"></ClientEvents>
        </telerik:RadAjaxManager>

    ASPX
    <telerik:RadAjaxManagerProxy runat="server" >
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="ddlPAptLot">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnlAptNbrLwr" UpdatePanelCssClass="" />                   
                        <telerik:AjaxUpdatedControl ControlID="pnlAptNbrLbl" UpdatePanelCssClass="" />
                       
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="ddlMAptLot">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnlMAptNbrLwr" UpdatePanelCssClass="" />                   
                        <telerik:AjaxUpdatedControl ControlID="pnlMAptNbr" UpdatePanelCssClass="" />
                       
                    </UpdatedControls>
                </telerik:AjaxSetting>          
                <telerik:AjaxSetting AjaxControlID="rdbDiff">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnlMailingAddr" UpdatePanelCssClass="" />
                        <telerik:AjaxUpdatedControl ControlID="pnlOutCountry" UpdatePanelCssClass="" />
                        <telerik:AjaxUpdatedControl ControlID="rdbSame" UpdatePanelCssClass="" UpdatePanelRenderMode="Inline" />
                       
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="rdbSame">
                   <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnlMailingAddr" UpdatePanelCssClass="" />
                        <telerik:AjaxUpdatedControl ControlID="pnlOutCountry" UpdatePanelCssClass="" />
                        <telerik:AjaxUpdatedControl ControlID="rdbDiff" UpdatePanelCssClass="" UpdatePanelRenderMode="Inline" />
                       
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="rdbOutsideUSYes">
                   <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnlMailingAddr" UpdatePanelCssClass="" />
                        <telerik:AjaxUpdatedControl ControlID="pnlOutCountry" UpdatePanelCssClass="" />
                       <telerik:AjaxUpdatedControl ControlID="rdbOutsideUSNo" UpdatePanelCssClass="" UpdatePanelRenderMode="Inline" />
                        
                    </UpdatedControls>
                </telerik:AjaxSetting>           
                <telerik:AjaxSetting AjaxControlID="rdbOutsideUSNo">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnlMailingAddr" UpdatePanelCssClass="" />
                        <telerik:AjaxUpdatedControl ControlID="pnlOutCountry" UpdatePanelCssClass="" />
                        <telerik:AjaxUpdatedControl ControlID="rdbOutsideUSYes" UpdatePanelCssClass="" UpdatePanelRenderMode="Inline" />
                         
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
            
        </telerik:RadAjaxManagerProxy>


  5. John
    John avatar
    22 posts
    Member since:
    Apr 2012

    Posted 10 Dec 2013 Link to this post

    As I workaround I've added the property EnableClientScript="False" to my RegularExpressionValidator and now the problem has gone away.
Back to Top