RadMaskedTextBox interperts delete key as space

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

    Posted 14 Nov 2013 Link to this post

    I've got a strange issue where the RadMaskedTextBox will accept a delete keystroke as a space character (overwriting any previous value and advancing the cursor) when the mask is set to accept only numbers. Expected functionality is for the delete key to delete the character to the immediate right of it, and for the cursor to remain in the same place.

    Suppose my RadMaskedTextBox has the following input

    1234
     ^---Cursor
    after delete key press
     234
      ^---Cursor
    after delete key press
      34
       ^---Cursor
    after delete key press
       4
        ^---Cursor
    after delete key press   
         ^---Cursor

    <telerik:RadMaskedTextBox ID="txtbox" class="numeric" PromptChar=""  SelectionOnFocus="SelectAll"
     runat="server" Width="44px" MaxLength="4" Mask="####" DisplayMask="****" DisplayText="" TabIndex="4"
       HideOnBlur="True" AutoCompleteType="Disabled"></telerik:RadMaskedTextBox>

    Reproduced on latest Firefox and Chrome. Using v2013.3.1114.40
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 19 Nov 2013 Link to this post

    Hello John,

    It is the expected behavior, because it is masked box. You have specific mask, and chars inside in exact location of the mask that they could not be placed in different location.

    When you delete a char, it will be invalid to move all right chars to left.

    For example
    If you have mask:
    "(###)###-####"
    And you have entered
    "(#11)234-9999"
    And you delete the first "1"
    It should be like:
    "(##1)234-9999"
    And not like
    "(#1)234-9999?" //because it is invalid, and does not match the mask.
    "(###)###-####"

    If you do not want the masked behavior, then use regular RadNumericTextBox for your case.

    Regards,
    Vasil
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. John
    John avatar
    22 posts
    Member since:
    Apr 2012

    Posted 20 Nov 2013 Link to this post

    Hi Vasil,

    Thank you for your reply. It makes a lot of sense. I cannot use a NumericTextBox however, as I need leading zeros to be preserved.

    Thanks,

    John
Back to Top