Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Regular expression for validate phone numbers. (See related posts)

   1  
   2  function checkPhone(str) 
   3  {
   4  	var phone2 = /^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/; 
   5  	if (str.match(phone2)) {
   6     		return true;
   7   	} else {
   8   		return false;
   9   	}
  10  }


Phone format
phone:
339-4248
339-42-48
339 42 48
339 4248
3394248
(095) #phone#
(095)#phone#
+7 (095) #phone#
+7 (095)#phone#
+7(095) #phone#
+7(095)#phone#

You need to create an account or log in to post comments to this site.


Click here to browse all 5307 code snippets

Related Posts