Expresso Phone Numbers

by Erik Lane 20. January 2005 02:13

Ok, a quick post that I'm sure regular RegEx users use and/or are aware of.  I've used Expresso before to get their already made expressions and to test others I have.  But last night I needed one for a specific phone number requirement on a field...not the one Expresso had built-in.  So I used their designer interface.  Pretty cool.  So after about 5 mins I had this script to validate a phone number that had to be formatted as xxx-xxx-xxxx.  Not too complicated but I was happy that I got it to work and now I know I can build more complicated ones in their designer.

function ValidPhoneNumber(phoneNumber)
{
	var filter=/\d{3}-\d{3}-\d{4}/;
	if (filter.test(phoneNumber))
		return true;
	else
		return false;
}
Tags:

Comments

Yex
Yex on 1/20/2005 3:40:00 AM

Nice. Regular expressions are VERY cool, and not used nearly as often as I feel they should be in applications. They really can save a lot of coding in the long run.

Dave Burke
Dave Burke on 1/21/2005 1:42:00 AM

Expresso looks great, especially for regEx phobes like me.  Will definitely check it out.  Thanks!

Scott Dockendorf
Scott Dockendorf on 1/27/2005 2:41:00 AM

weblogs.asp.net/.../253482.aspx" rel="nofollow">weblogs.asp.net/.../253482.aspx">weblogs.asp.net/.../253482.aspx" rel="nofollow">weblogs.asp.net/.../253482.aspx

RegExLib.com ROCKS!  Check it out!

eriklane
eriklane United States on 1/27/2005 2:48:00 AM

Thanks Scott.  That site is great!

Comments are closed