Начало
Формы
Ратификация (SSN)
Введите Номер социального страхования, используя или 9 цифр или формат NNN-NN-NNNN.
SS #:
(use dashes!)
JavaScript Forms: Ратификация (SSN)
<!-- TWO STEPS TO INSTALL VALIDATION (SSN): 1. Copy the coding into the HEAD of your HTML document 2. Add the last code into the BODY of your HTML document --> <!-- STEP ONE: Paste this code into the HEAD of your HTML document --> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <! > <! > <!-- 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> </HEAD> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <BODY> <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> <!-- Script Size: 1.54 KB -->