Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dear sir,

I have found some problem when implemented the validation code in c#. The telephone number and email id should be following pattern.

Telephone number is as follows:
1. " nnn - nnn nn nn " in case of Big Cities.
1. " nnnn - nn nn nn " in case of Small Towns.

For Zwolle (Big Cities) : 038 - 123 45 67
For xyzTown(Small Cities/Town) : 0381 - 12 34 56


For email id:-

more than one @ symbol should not appear..

The code should be in C# and displayed the message on the asp.pages but the message should be displayed on the runtime and also not used javascript and validation extender and the code should be used c# only.

thanks in advanced...
Posted
Updated 5-Jan-12 2:10am
v2

Hi,

For this requirement you can use the built in regular expression validator. in that you have,
German Phone Number Validator
Email Validation and so many things
Even if you want your own requirement you can specify that also using the regular expressions..

Hope this helps you and this is what you want..
 
Share this answer
 
See this Regular expression examples..
Here[^]
 
Share this answer
 
If I understood the spec correctly, you could use for the telephone a regular expression like:
C#
(\d){3,4} - (\d){2,3} (\d){2} (\d){2}

However, it's a good thing to validate the input but if the input always follows strict rules, in my opinion it would be better to eliminate the errors already in the user interface. For this consider using a masked edit control.For example:
- MaskedEdit Demonstration[^]
- Mask TextBox ASP.NET Control[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900