Validate a textbox by country code format

Posted by Jopito under ASP.NET on 1/10/2014 | Points: 10 | Views : 1424 | Status : [Member] | Replies : 4
Hellow pals,i need to have a regular expression which ensures only number entered in a textbox start with a certain format of country code e;g a phone number to start with a code.How can i do this .e.g 600123321567

Mark as answer if satisfied


Responses

Posted by: kgovindarao523-21772 on: 1/10/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

If your phone number starts with code :60 ,and have ten 10 digits after code.
Regular expression is:

^60\d{10}$

Thank you,
Govind

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jopito on: 1/10/2014 [Member] Starter | Points: 25

Up
0
Down
This one cannot validate the entered text.have entered a number but cannot pick

Mark as answer if satisfied

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: kgovindarao523-21772 on: 1/10/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,
Here is the javascript code.
Regular expression is ^60[0-9]{10}$
function myfunction()

{
var str = '600123321567';
var patt = new RegExp("^60[0-9]{10}$ ", "i");
alert(patt.test(str));

}

Please not that, Only numerics are accepted, not alphabets.
Please mark as answer , if you got your requirement

Thank you,
Govind

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: vishalneeraj-24503 on: 1/10/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
You can use MaskEditExtender ajax control for working with your scenarios.
You can use below links:-

http://www.asp.net/ajaxlibrary/ajaxcontroltoolkitsamplesite/maskededit/maskededit.aspxhttp://asp-net-example.blogspot.in/2009/11/ajax-maskededitextender-masktype-time.html

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response