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

Way to Determine Mask Length

1 Answer 17 Views
Input
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 21 Oct 2014, 06:06 PM
Is there a method to determine the number of masked characters in a RadMaskedTextBox.Mask?  For example, if the mask is defined as "###-###-#### (US)" the number of masks is 10 (whereas the length of the mask would be 17).

I've looked at the MaskParts collection, but don't see a simple way of determining the number of masks (vs. literals).

Any help would be appreciated so I don't recreate the wheel!

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 24 Oct 2014, 01:28 PM
Hello Matt,

In order for retrieving the length of the mask with and without the literals, you could use the get_valueWithPrompt() and get_valueWithPromptAndLiterals() methods:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function pageLoad() {
            var maskedTextBox = $find("<%=RadMaskedTextBox1.ClientID%>");
            var withoutLiterals = maskedTextBox.get_valueWithPrompt().length;
            var withLiterals = maskedTextBox.get_valueWithPromptAndLiterals().length;
            debugger;
        }
    </script>
</telerik:RadCodeBlock>
 
<telerik:RadMaskedTextBox runat="server" ID="RadMaskedTextBox1" Mask="###-###-#### (US)"></telerik:RadMaskedTextBox>

On server-side you could use the following:
RadMaskedTextBox1.TextWithPromptAndLiterals.Length
RadMaskedTextBox1.TextWithPrompt.Length


Best Regards,
Konstantin Dikov
Telerik
 

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.

 
Tags
Input
Asked by
Matt
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or