|
For answers to some of the finer points on javascript, including samples, you may want to check out http://www.javascript.com or http://www.htmlgoodies.com and http://www.javascripts.com At http://javascript.internet.com/forms/val-ssn.html was this code to validate a Social Security number: <!-- 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"> <!-- Original: Carol Gevers --> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Begin function SSNValidation(ssn) { if (ssn.length != 9) { alert("Error! A Social Insurance Number must contain exactly 9 digits, please try again."); return false; } else { var num1 = ssn.charAt(0); var num2 = ssn.charAt(1); var num3 = ssn.charAt(2); var num4 = ssn.charAt(3); var num5 = ssn.charAt(4); var num6 = ssn.charAt(5); var num7 = ssn.charAt(6); var num8 = ssn.charAt(7); var num9 = ssn.charAt(8); var step1 = 2 * (num2 + num4 + num6 + num8); var step2 = 0; var tempNum = Math.floor(step1 / 10000); step2 += tempNum; step1 -= (tempNum * 10000); tempNum = Math.floor(step1 / 1000); step2 += tempNum; step1 -= (tempNum * 1000); tempNum = Math.floor(step1 / 100); step2 += tempNum; step1 -= (tempNum * 100); tempNum = Math.floor(step1 / 10); step2 += tempNum; step1 -= (tempNum * 10); tempNum = Math.floor(step1 / 1) step2 += tempNum; var step3 = num1 + num3 + num5 + num7; tempNum = Math.floor(step3 / 1000); step2 += tempNum; step3 -= (tempNum * 1000); tempNum = Math.floor(step3 / 100); step2 += tempNum; step3 -= (tempNum * 100); tempNum = Math.floor(step3 / 10); step2 += tempNum; step3 -= (tempNum * 10); tempNum = Math.floor(step3 / 1) step2 += tempNum; tempNum = Math.floor(step2 / 10); valid = 10 - (step2 - (tempNum * 10)); var num = num1 + num2 + num3 + "-" + num4 + num5 + "-" + num6 + num7 + num8 + num9; if (valid == 10) valid -= 10; if (valid == num9) msg = "is a valid"; else msg = "is not a valid"; alert(num + "\r\n\r\n" + msg + " Social Security Number."); } } // End --> </script> </HEAD> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <BODY> <center> <form> <tt> SS #: <input type=text name=ssn size=9 maxlength=9> (no dashes!) </tt> <p> <input type=button value="Validate Number" onClick="SSNValidation(this.form.ssn.value);"> </form> </center> <p><center> <font face="arial, helvetica" size="-2">Free JavaScripts provided<br> by <a href="http://javascriptsource.com">The JavaScript Source</a></font> </center><p> <!-- Script Size: 2.32 KB --> "Gibbons, Michael" wrote: > > Hi Folks, > Thanks for answering my midrange question (CGI Fact Finding > Mission). I was hoping you could clarify JS data validation. MY project is > going to ask for a social security number and a PIN number and I am not > quite were I need to encrypt it. Do I use java scripting and can I validate > these fields as numbers and that they are valid DB accounts (Back to the > as400). And if I don't use cookies can I pass an id number back and forth > with java scripting. Is there sample code available ? > > Or, do I use a server side CGI using SSL to do this and do I do it > in RPG or Java. The same Parameter issues would apply. Is there sample code > available ? > +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.