US Social Security Number Validation Script

US Social Security Number Validation Script is use to validate a us social security number through regular expression.

Demo :



  Validate Social Security Number :    

Example :

Just type a proper social security number like this 123-45-6789 and click check button Is a properly-formatted US Social Security Number message will display otherwise type a 12346 number at textbox and click check button Is an improperly-formatted US Social Security Number will display here.

Code :

Following code is use to US Social Security Number Validation Script if you need to copy and use to your website.


<?php
  function validateSSN($str)
  {
    return preg_match("/^\d{3}\-\d{2}\-\d{4}$/", $str);
  }
  $SSN_no = "123-45-6789";
  echo validateSSN("$SSN_no") ? "Is a properly-formatted SSN" : "Is an improperly-formatted SSN";
?>

In the above $SSN_no variable is use to assign the us social security number. In the validateSSN() function is use to check the validate us social security number through regular expression.

Free Download Script :

If you need to US Social Security Number Validation Script click and download from following link.

Download




Content