RadMaskedTextBox with Validators cannot be exited

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

    Posted 28 May 2014 Link to this post

    I have a form with a number of fields before a RadMaskedTextBox and a number of fields after. In Chrome or Opera, when the focus is placed on the RadMaksedTextBox, the validation must pass, or you cannot tab or click out of the field, which is not the expected behavior. Here is an example exhibiting this behavior.

    <!DOCTYPE html>
    <head runat="server">
        <form id="form1" runat="server">
                 <telerik:RadScriptManager ID="RadScriptManager1" AjaxFrameworkMode="Enabled" runat="server" CompositeScript-ScriptMode="Auto" EnableEmbeddedjQuery="False" LoadScriptsBeforeUI="False" OutputCompression="AutoDetect"></telerik:RadScriptManager>
                 <telerik:RadMaskedTextBox ID="txtSSN4" class="numeric" PromptChar="" SelectionOnFocus="SelectAll" runat="server" Width="44px" MaxLength="4" Mask="####" DisplayMask="****" DisplayText=""
                                                    TabIndex="4" meta:resourcekey="txtSSN4Resource1" HideOnBlur="True" AutoCompleteType="Disabled">
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" Text="*" ForeColor="Red"
                                                            ControlToValidate="txtSSN4" ErrorMessage="SSN4 is required." meta:resourcekey="RequiredFieldValidator3Resource1" SetFocusOnError="True"></asp:RequiredFieldValidator>
                                                <asp:RegularExpressionValidator runat="server" meta:resourcekey="SSN4RangeValidatorResource1" ID="SSN4RangeValidator" ForeColor="Red" ControlToValidate="txtSSN4" Text="Format is incorrect." ErrorMessage="SSN4 format is incorrect." ValidationExpression="[0-9]{4}" SetFocusOnError="True"></asp:RegularExpressionValidator>               
                <asp:TextBox runat="server" ID="abc"></asp:TextBox>
  2. Viktor Tachev
    Viktor Tachev avatar
    1444 posts

    Posted 02 Jun 2014 Link to this post

    Hello John,

    I tested the provided code and it seems that the described behavior is due to the SetFocusOnError property of the Validator controls. Try removing the property or set it to false and the next input should be focused when the Tab key is pressed.

    Viktor Tachev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. DevCraft R3 2016 release webinar banner
Back to Top