Hi,
Is there a way to set a mask on the standard ASP.NET TextBox Web control? For example, I need to mask the input and display of a telephone number "###-###-####".

Thanks,
Mike

Recommended Answers

All 2 Replies

There isn't any 'built-in' to dot net.

The best way is to use regular expressions to validate the input on the client and then also format it how you want for the DB serverside.

This is best because it allows the user to put (000) 000 0000 or 0000000000 or 000-000-0000 however they like but by time gets to DB is always 000-000-00000

I think masks have not been implemented because really they closely couple your UI with your data model which is not good practice. Regular expressions allow you to keep things independant.

Doing it this way worked out fine. Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.