Script Categories













Forms >>> Validation Social Security Number.

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.

SS #: (use dashes!)

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
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.");
   }
}
//  End -->
</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>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).




©