Nikerz Inc wrote:
> Hi there, that sounds great would you happen to have any code
> samples?? I'm new to asp.net which doesn't help but I noticed that
> alot of sites are using three text boxes for a phone number instead
> of one I wonder if that is from the difficulty of making the code to
> validate the box.
No, it's rather to make it easy for the users to fill in the right format
(do I write slashes or dashes?)
As an alternative solution for this useability problem, you could show
an example next to the text box so that the user doesn't have to guess.
Validating phone numbers is actually very easy in asp.net:
1) add a RegularExpressionValidator to your form.
2) Make its ControlToValidate property point to the right text box
3) Modify the ErrorMessage to your own convenience
4) Set the ValidationExpression to your phone format, e.g.
"^\d{3}/\d{7}$" for the 012/3456789 format.
The rest is automatic, no code needed!
It will even do client-side validation (IE only).
If you're not familiar with regular expressions, you might want
to check www.regular-expressions.info, or download the free
Expresso program.
--
Jos