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

Ajax call breaks RadMaskedTextBox with RegularExpressionValidator

3 Answers 56 Views
Input
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 2
John asked on 03 Dec 2013, 06:05 PM
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>

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Dec 2013, 03:52 AM
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.
0
John
Top achievements
Rank 2
answered on 09 Dec 2013, 10:29 PM
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>


0
John
Top achievements
Rank 2
answered on 10 Dec 2013, 03:15 PM
As I workaround I've added the property EnableClientScript="False" to my RegularExpressionValidator and now the problem has gone away.
Tags
Input
Asked by
John
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
John
Top achievements
Rank 2
Share this question
or