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;
    MessageBox.Show(txtPhone.Text);
    txtPhone.TextMaskFormat = MaskFormat.IncludePromptAndLiterals;
}

Happy Coding :)

Support My Work

If you find my content helpful, consider supporting my work. Your support helps me continue creating valuable resources for the community.

Share this article

Found this useful? Share it with your network!

Copyright © 2025 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