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

RadMaskedTextBox remove empty spaces on display

3 Answers 85 Views
Input
This is a migrated thread and some comments may be shown as answers.
Massimiliano
Top achievements
Rank 1
Massimiliano asked on 09 Feb 2014, 03:33 PM
Since I have variable widht numbers in my masked textbox I would like to remove the empty spaces when the textbox loses focus (on display).
So for example something that on focus appears like +39__-12__-1234____ should appear like +39-12-1234 when the box loose focus and not like +39  -12  -1234
Also it seems that pressing the "del" key leaves empty spaces. In a mask like ####-#### it doesn't make much sens to have 12 4-1 34 with spaces in the middle.
Of course when you retrieve the values all this is fixed but preventing it in the input and a correct display on blur would be nice. 

3 Answers, 1 is accepted

Sort by
0
Massimiliano
Top achievements
Rank 1
answered on 09 Feb 2014, 03:36 PM
I forgot to say I tryed a solution for the first issue (not for the prevention of empty spaces during input but for the removal on display) but it doesn't seem to work as expected:

                <telerik:RadMaskedTextBox ID="maskedOfficePhone" runat="server" CssClass="span3" Mask="+####-####-########"
                                          Rows="1" DisplayFormatPosition="Right" DisplayPromptChar=""
                                          PromptChar="_" EmptyMessage="Mobile phone" InvalidStyleDuration="150" AllowEmptyEnumerations="false" ClientEvents-OnBlur="stripmask"
                                          AutoCompleteType="Cellular" Text="+39-12-258" ResetCaretOnFocus="false" SelectionOnFocus="CaretToBeginning" NumericRangeAlign="Right">
                </telerik:RadMaskedTextBox>
 
<telerik:RadScriptBlock runat="server">
    <script type="text/javascript">
        function stripmask(sender, eventArgs) {
            alert(sender.get_valueWithLiterals());
            sender.set_value(sender.get_valueWithLiterals().replace(' ',''));
        }
    </script>
</telerik:RadScriptBlock>
0
Viktor Tachev
Telerik team
answered on 12 Feb 2014, 12:59 PM
Hi Massimiliano,

When a Mask is set for the RadmaskedTextBox  the input expects the number of characters that are set in the mask. If less characters are entered the PromptChar symbol is displayed in the empty places.

If you need ho handle a situation where phone numbers with various length will be entered you could use two RadNumericTextBox controls - one for the area code and one for the number.

Regards,
Viktor Tachev
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 UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Rana
Top achievements
Rank 1
answered on 14 Dec 2020, 07:45 PM

When we made :

<input kendo-numeric-text-box k-format="'#'" ng-model="searchParams.@Model.ParameterName"/>

when I paste "123456 " with space if some number is copied and paste  it should truncate empty space and keep the number. how can I achieve this?

Tags
Input
Asked by
Massimiliano
Top achievements
Rank 1
Answers by
Massimiliano
Top achievements
Rank 1
Viktor Tachev
Telerik team
Rana
Top achievements
Rank 1
Share this question
or