# Beginner! Need Help! đ

validate check for social insurance number.

social insurance number: only 9 digits (1-9), only number, should be input in three boxes, 3 digit in each boxes( if possible use auto tab)

add the odd digits : means 1th,3dr,5th,7th, 9th digits together = odd digits sum value

Extract the even digits: mean 2nd, 4th, 6th, 8th digits-- and multiply by *2, add all the even digits together only if it is less than 10

if the 2nd, 4th, 6th, 8th digits is greater than 10 then , add like this ( for eg the 4th digit is 18 then add= 1+8)

Then,

odd digits sum value + the even digit sum value = multiple of ten (%10)

<!DOCTYPE >

<html>

<title></title>
<body>
<script type=âtext/javascriptâ>
function Validation(sin)
{
var num = sin.match(/^(\d{3})-?\d{3}-?\d{3}\$/);

``````var numDashes = sin.split('-').length - 1;
if (num == null || numDashes == 1) {
alert('Invalid S.I.N. Must be 9 digits or in the form NNN-NNN-NNN.');
msg = "does not appear to be valid";
}
else
if (parseInt(num[1], 10) == 0) {
msg = "does not appear to be valid";
}
else {
msg = "appears to be valid";
``````

\r
" + msg + " Social Insurance Number.");
}

``````     if (!num.test(sin)) return false;
sin = sin.split("-").join("");
var checksum=0;
for (var n = (2 - (sin.length % 2)); n &lt;= sin.length; n += 2) {
checksum += parseInt(sin.chartAt(n - 1));
for (var n = (sin.length % 2) + 1; n &lt; sin.length; n += 2)
var digit = parseInt(sin.charAt(n - 1)) * 2
if (digit &lt; 10) {
checksum += digit;
}
else {
checksum += (digit - 9);
}
}
if ((checksum % 10) == 0) return true; else return false;
}

&lt;/script&gt;
``````

<form>
<tt>
SIN #: <input type=âtextâ name=âsinâ size=â11â maxlength=â11â/> (use dashes!)
</tt>
<br/><br/>
<input type=âbuttonâ value=âValidate Numberâ onclick=âValidation(this.form.sin.value)â/>
</form>
</body>

</html>

Code is Not Working!!!

Can u Sent me a Solution for this!!!

Welcome to the SP forums.

This wouldnât be a homework assignment, would it?

Code is Not Working!!!

Why? What is happening? An error? A wrong result? Could you explain a bit more?

My calculation is perfect,
I donât know how to put in three input boxes,
There is something wrong with the function value and input function,
If you have any time can you plz work on my code and post the correct one will be great!!!(:

Thx for the response