Restrict phone number to accept only numbers, dashes, plus sign and bracket
i have a text box for user to key in the phone number. I want restrict that textbox to accept only the numbers, dashes, plus sign and bracket. Please advise if this is possible.
Re: Restrict phone number to accept only numbers, dashes, plus sign and bracket
It's possible in a few ways. You can have a javascript method that gets called whenever the textbox's text changes, this method can look for and remove any of the characters that aren't in a predetermined set.
You can use a RegularExpressionValidator in ASP.NET that specifies a regex that would match a valid phone number and have it validate both on client side and codebehind.
Re: Restrict phone number to accept only numbers, dashes, plus sign and bracket
You could also jump into AJAX and use its' masked text boxes.. pretty slick stuff, that AJAX.