JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 23rd, 2012, 12:29 PM
sumanthan sumanthan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 1 sumanthan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 2 sec
Reputation Power: 0
Beginner!!!! Need Help!!! :confused:

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>

<head>
<title></title>
</head>
<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) {
alert("Invalid SIN: SIN's can't start with 000.");
msg = "does not appear to be valid";
}
else {
msg = "appears to be valid";
alert(sin + "\r\n\r\n" + 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 <= sin.length; n += 2) {
checksum += parseInt(sin.chartAt(n - 1));
for (var n = (sin.length % 2) + 1; n < sin.length; n += 2)
var digit = parseInt(sin.charAt(n - 1)) * 2
if (digit < 10) {
checksum += digit;
}
else {
checksum += (digit - 9);
}
}
if ((checksum % 10) == 0) return true; else return false;
}

</script>
<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!!!!!!!

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Beginner!!!! Need Help!!! :confused:

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap