How can I validate US Social Security Number?

后端 未结 8 1464
鱼传尺愫
鱼传尺愫 2020-12-08 02:44

Anyone out there know how to improve this function? I\'m not worried about shortening the code, I\'m sure this could be done with better regex, I am more concerned about cor

8条回答
  •  自闭症患者
    2020-12-08 03:29

    UPDATE

    On June 25, 2011, the SSA changed the SSN assignment process to "SSN randomization".[27] SSN randomization affects the SSN assignment process in the following ways:

    It eliminates the geographical significance of the first three digits of the SSN, previously referred to as the Area Number, by no longer allocating the Area Numbers for assignment to individuals in specific states. It eliminates the significance of the highest Group Number and, as a result, the High Group List is frozen in time and can be used for validation of SSNs issued prior to the randomization implementation date. Previously unassigned Area Numbers have been introduced for assignment excluding Area Numbers 000, 666 and 900–999.

    New Rules

    • The Social Security number is a nine-digit number in the format "AAA-GG-SSSS". The number is divided into three parts.
    • The middle two digits are the Group Number. The Group Numbers range from 01 to 99.
    • The last four digits are Serial Numbers. They represent a straight numerical sequence of digits from 0001 to 9999 within the group.
    • Some special numbers are never allocated:
      • Numbers with all zeros in any digit group (000-##-####, ###-00-####, ###-##-0000).
      • Numbers with 666 or 900-999 (Individual Taxpayer Identification Number) in the first digit group.
    • SSNs used in advertising have rendered those numbers invalid.

    http://en.wikipedia.org/wiki/Social_Security_number#Structure

    Previous Answer

    Here's the most-complete description of the makeup of an SSN that I have found.

提交回复
热议问题