The ASP Emporium
Free Active Server Applications and Examples by Bill Gearhart
Online since Friday January 7, 2000

 home > code > code library > ECommerce Procedures > isSSN Function

enter a phrase to search: (advanced search)


 h o m e 

 w h a t 's  n e w 

 a l l   c o d e 
  .net:
    • Fundamentals
    • C# Classes
  classic asp:
    • Code Library
    • ASP Apps
  general:
    • Tutorials
    • SQL

 d o w n l o a d s 

 u s e r   f o r u m s 

 l i n k s 

 s e a r c h 

 s u p p o r t 


isSSN Function   v1.0   [JScript]

< prev proc
IsJSReady Function
next proc >
IsState Function

purpose:
Determines whether or not a string follows the format of a U.S. 
Social Security Number.
syntax:
var string = isSSN(ssnToTestString);
example usage:
var string1 = "555-45-5678";
var string2 = isSSN(string1);
source code:
function isSSN(strIn) {
	strIn = "" + strIn + "";

	//validate a social security number for proper syntax
	var re = /^\d{3}\-?\d{2}\-?\d{4}$/i
	return re.test(strIn);
}
< prev proc
IsJSReady Function
next proc >
IsState Function