Link to home
Start Free TrialLog in
Avatar of minglelinch
minglelinch

asked on

Phone # formatted textbox

I want to have a phone number textbox with a mask with format like xxx-xxx-xxxx, so that no matter what user types it always have the standard format. I like the mask do the job instead my javascript function check the format. How can I do it? Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can use a regular expression validator in .net.  Here's an example:
<asp:RegularExpressionValidator ID="ValidatorRegEx_Phone" runat="server"
                    ValidationGroup="SomeGroup"
                    ControlToValidate="TextBox_Phone"
                    ValidationExpression="((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}"
                    Text="Invalid telephone number!">
                </asp:RegularExpressionValidator>

Open in new window

Avatar of minglelinch
minglelinch

ASKER

Thanks for all the comments.  
The example in emoreau's is execellent.
I choose ged325's as it is simpler.