|
Forms >>>
Input the Social Security Number using either the 9 digit or NNN-NN-NNNN format. The number ranges can be easily changed by the S.S.A, so this is not checked.
Add the below code to the <body> section of your page:
<script
language="javascript"
type="text/javascript">
function
SSNValidation(ssn)
{
var
matchArr =
ssn.match(/^(\d{3})-?\d{2}-?\d{4}$/);
var
numDashes =
ssn.split('-').length
-
1;
if
(matchArr
==
null
||
numDashes ==
1)
{
alert('Invalid
SSN. Must be 9 digits or in the form NNN-NN-NNNN.');
msg
=
"does not appear to be valid";
}
else
if
(parseInt(matchArr[1],10)==0)
{
alert("Invalid
SSN: SSN's can't start with 000.");
msg
=
"does not appear to be valid";
}
else
{
msg
=
"appears to be valid";
alert(ssn
+
"\r\n\r\n"
+
msg +
" Social Security Number.");
}
}
</script>
<form>
<tt>
SS #:
<input
type=text
name=ssn
size=11
maxlength=11>
(use dashes!)
</tt>
<br><br>
<input
type=button
value="Validate
Number"
onClick="SSNValidation(this.form.ssn.value);">
</form>
|
↓
|