Validating a social security number
In today’s post I’ll show you how to use Java Script regular expression to validate Social Security number. The argument to this method is the social security number you want to validate.In the method body we define a variable (‘ssn Pattern’) and assign a regular expression to it.Before 1965, only half the group numbers were used: odd numbers were used below 10 and even numbers were used above 9.In 1965 the system was changed so assignments continued with the low even numbers and the high odd numbers.Each time something is not inputted an appropriate message is added to the previous error_message on a new line using the \n to get the new line.If the error_message isn't entirely blank the user gets feedback about what is missing.
On the final line we call test method for our regular expression and pass the social security number as input.
So, group numbers for each area number are assigned in the following order: Group codes of "00" aren't assigned In each region, all possible area numbers are assigned with each group number before using the next group number.
This means the group numbers can be used to find a chronological ordering of SSNs within a region.
A Social Security Number (SSN) consists of nine digits, commonly written as three fields separated by hyphens: AAA-GG-SSSS.
The first three-digit field is called the "area number".