Simple SSN Validation Script

Simple SSN Validation Script. Strips unwanted dashes and validates filed entry.
function checkSSNLength()
{
var q = document.forms[0].SocSecNo.value;
var a = q.charAt(0);
var b = q.charAt(1);
var c = q.charAt(2);
var d = q.charAt(3);
var e = q.charAt(4);
var z = q.charAt(5);
var y = q.charAt(6);
var h = q.charAt(7);
var i = q.charAt(8);
var j = q.charAt(9);
var k = q.charAt(10);
if ((q.length == 11 ) && (d == "-") && (y == "-"))
{
var a = q.charAt(0);
var b = q.charAt(1);
var c = q.charAt(2);
var e = q.charAt(4);
var z = q.charAt(5);
var h = q.charAt(7);
var i = q.charAt(8);
var j = q.charAt(9);
var k = q.charAt(10);   
var finalString = a + b + c + e + z + h + i + j + k;
document.forms[0].SocSecNo.value = finalString;  
checkSSINumber();            
}else
if (q.length == 9)
{
checkSSINumber();  
return true;    
}else
if ((q.length > 11) || (q.length < 9))
{
alert("As we all know, unless the US Government has changed Social Security Policyn" +
"overnight, the maximum number of digits for a social security number is 11 if you include dashes.nnn" +
"For example: 123-45-6789 or 123456789.  If you need additional help or instructionsn" +
"pertaining to this matter please contact your local representative to discuss this matter....Thank You!!!");
document.forms[0].SocSecNo.focus();
document.forms[0].SocSecNo.select();
return false;
}
} 
function checkSSINumber()
{
var f = document.forms[0].SocSecNo.value;
var tempNum = Math.floor(f/10000);
var tempNum1 = Math.floor(tempNum/1000);
var tempNum2 = Math.floor(tempNum1/100);
var tempNum3 = Math.floor(tempNum2/10);

if ((f.length < 9) || (f.length > 9) || (tempNum3 != 0))
{
alert("Not a valid SSN number");
document.forms[0].SocSecNo.focus();
document.forms[0].SocSecNo.select();
}
else
alert("Valid SSN");
}
This was last published in February 2001

Dig Deeper on Lotus Notes Domino Email Encryption

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close