Click here to Skip to main content
15,890,370 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to validate indian land line numbers using regex which allows numbers,parentheses,space
Posted
Comments
Peter Leow 6-Dec-13 4:16am    
Could you show us an example of a land line number with numbers, parentheses and space?
shanthini24 6-Dec-13 4:40am    
(0412) 123456
Peter Leow 6-Dec-13 4:51am    
Thanks. I have sent in my solution, hope it helps.

Hi
Try this regular expression may it will help

C#
mobile no..

^9\d{9}$



For Landline number..


/^[0-9]\d{2,4}-\d{6,8}$/
 
Share this answer
 
Comments
shanthini24 5-Dec-13 23:50pm    
whether it accept parentheses?
Hope this helps:

[(]\d{4}[)]\s\d{6}
 
Share this answer
 
v2
use keypress event and handle any other character you don't want with
e.handle = true;
 
Share this answer
 
Comments
Pete O'Hanlon 13-Dec-13 6:55am    
Err no. That's not the way to handle this. What about if I were to paste AAA-AAAA-AAAAAAA into the textbox?
agent_kruger 14-Dec-13 7:20am    
then regex is the only alternative as it works on paste also.

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