How to get text from Masked Text Box without the masked format

June 02, 2014 by Anuraj

.Net .Net 3.0 / 3.5 .Net 4.0 Windows Forms

Today I saw some SO question asked about how to get values from Masked Textbox without the masked format. For those who don’t know what is masked textbox - Uses a mask to distinguish between proper and improper user input.

Masked Textbox - With Phone Number mask property

Here is the code snippet.

//Make sure user completed the entry.
if (txtPhone.MaskFull)
    txtPhone.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
    txtPhone.TextMaskFormat = MaskFormat.IncludePromptAndLiterals;

Happy Coding :)

Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub