»
EnglishFrenchVietnamese

Print - Validation (SSN) - JavaScriptBank.com

Full version: jsB@nk » Form » Validation » Validation (SSN)
URL: https://www.javascriptbank.com/validation-ssn.html

Validation (SSN) © JavaScriptBank.comInput 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.

Full version: jsB@nk » Form » Validation » Validation (SSN)
URL: https://www.javascriptbank.com/validation-ssn.html



JavaScript
<SCRIPT LANGUAGE="JavaScript">// Carol Gevers// Sandeep V. Tamhankar (stamhankar@hotmail.com)<!-- Beginfunction 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><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form><tt>SS #:  <input type=text name=ssn size=11 maxlength=11> (use dashes!)</tt><p><input type=button value="Validate Number" onClick="SSNValidation(this.form.ssn.value);"></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->