Click here to Skip to main content
14,929,655 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am developing a windows form application in .net c#, All I want to know is how to validate the Indian phone number, if a user inputs in a textbox.
Posted
Updated 23-Nov-17 19:58pm
Comments
   
Is it because of using Indo-Arabic numerals? Or is it more simple?
--SA

1) first you create range validator from validation control in toolbox.

2) After that which textbox in need phoneno that textbox rightclick and goto properties see a)min value fix=0, max value=9, Error msg=Enter correct format and control to validator that textbox id. That solve
   
I think it may help you....

Validate user input in Windows Forms[^]
   
Comments
zainemma 1-Mar-12 4:57am
   
Thanks ramuAlla, that helped me a lot, Cheers!!!
Member 10290905 3-Jan-14 4:32am
   
i need to phone number validation in c# please help me i new in window application
Use either Regular Expressions or masked textBox.

You should trust your googling skills as well.
   
Comments
zainemma 1-Mar-12 4:57am
   
Thanks for that answer friend, that was Useful.
thatraja 1-Mar-12 7:51am
   
Reg expression is right choice, My 5!
C#
System.Text.RegularExpressions.Regex expr;

        public bool email(string email)
        {
            expr =new  Regex(@"^[a-zA-Z][\w\.-]{2,28}[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");
            if (expr.IsMatch(email))
            {
                return true;
            }
            else return false;
        }
        public bool phone(string no)
        {
            expr = new Regex(@"^((\+){0,1}91(\s){0,1}(\-){0,1}(\s){0,1}){0,1}9[0-9](\s){0,1}(\-){0,1}(\s){0,1}[1-9]{1}[0-9]{7}$");
            if (expr.IsMatch(no))
            {
                return true;
            }
            else return false;
        }
   

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