function IsValidNRIC(theNric) { var nric = []; nric.multiples = [2, 7, 6, 5, 4, 3, 2]; if (theNric.length != 9) { alert('Invalid NRIC') return false; } var total = 0, count = 0, numericNric; var first = theNric.charAt(0), last = theNric.charAt(theNric.length - 1); if (first != 'S' && first != 's') { alert('Invalid NRIC S'); return false; } /*Above is working*/ numericNric = theNric.substr(1, theNric.length - 2); if (isNaN(numericNric)) { alert('Invalid NRIC Middle Not a number') return false } if (numericNric != null) { while (numericNric != 0) { total += (numericNric % 10) * nric.multiples[nric.multiples.length - (1 + count++)]; numericNric /= 10; numericNric = Math.floor(numericNric); } } var outputs; if (first == 'S') { outputs = ['J', 'Z', 'I', 'H', 'G', 'F', 'E', 'D', 'C', 'B', 'A']; } if (first == 'T') { outputs = ['G', 'F', 'E', 'D', 'C', 'B', 'A', 'J', 'Z', 'I', 'H']; } if (last != outputs[total % 11]) { alert('Invalid end Character') return false; } nric.isNricValid = function (theNric) { if (!theNric || theNric == '') { return false; } } return true; }
Tuesday, July 30, 2013
NRIC(Singapore) Validation using Javascript
Subscribe to:
Post Comments (Atom)
MS CRM 2011 KB Article customization Issue.
Recently I have encountered some issue while customizing Kb Article Entity. I was doing following configuration in Article form. 1. Add Ba...
-
Recently I wanted to find out users who are not in the correct time zone in CRM System. To change the time zone or user related settings we ...
-
If you want to take part in the internet as a business, information resource, directory, or as a hobbyist wanting to share data, informatio...
-
Do you need to recover lost files, photos or documents? You're sure that a file was on your hard disk some time ago, but now it seems to...
this code is good can u help me
ReplyDeletehow to call his function from onblure attribute