You can use from the ASP.Net Validators available. You can make use of RegularExpression validator or may be custom validator for this purpose.
Also take a look at MaskedTextBox from the AjaxToolkit if that suits you.
Alternative: You can also do it using
javascript
. call following javascript function on button click.
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")
{
alert("it should start with 9 or 2 ");
return false;
}
}
for more detail check,
JavaScript: A Quick Check[
^]
Validate Phone Numbers: A Detailed Guide[
^]