Click here to Skip to main content
15,921,295 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Can anyone know?

How to validate phone Number in asp.net properly?
Posted
Comments
Balakrishnan Dhinakaran 15-Dec-11 0:08am    
please tell in which format you need to validate eg:+91-9000012345 ?
Ajana J 16-Dec-11 11:31am    
for the format +91-9000012345 what is the regular expression?

 
Share this answer
 
v2
You can do it using javascript. call following javascript function on button click.

JavaScript
function Validate()
{
  var x = document.getElementById("txtPhomenumber").value;
  if(isNaN(x)|| x.indexOf(" ")!=-1)
  {
     alert("Enter numeric value");
     return false;
  }
  if (x.length > 10 || x.length > 8 )
  {
     alert("enter 10 or 8 characters");
     return false;
  }
  if (x.charAt(0)!="9" || x.charAt(0)!="2")
  {
      alert("it should start with 9 or 2 ");
      return false;
  }
}


for more detail check, JavaScript: A Quick Check[^]
 
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