Validating social security cards

validating social security cards-69

This is obviously an old post, but I found some ways to shorten it.

Also there are a few specific numbers to invalidate according to this link: how I did it.

I could have used regexes for repeating numbers, but with specific ones to invalidate we might as well add ones through fives to that list (over 5 will invalidate anyways due to area number validation).

I also left out is Numeric(ssn) because the field is a numeric and already strips characters before calling the validate function. If someone is going to fake '321214321' they might as well fake '102319982' (and yes, I just typed that in randomly).

It goes against other (previous answers) and government documentation: "Previously unassigned area numbers were introduced for assignment excluding area numbers 000, 666 and 900-999."function check SSN() { var input SSN = #Your Input#, ssn Regex = new Reg Exp("^(9[0-9][0-9]|666|000|078051120|219099999|123456789|123121234|321214321)|^([0-8][0-9][0-9]00)|^([0-8][0-9][0-9][0-9][0-9]000)$"), repeats = /^(.)\1 $/; //make sure we have 2 dashes in the input Social Security number if( input SSN.match(/./g).length === 2) For the ssn Regex logic: The first section handles if the SSN starts with a number 900-999, 666, 000, or one of the known disqualifying SSNs mentioned above.