Created
August 3, 2012 21:54
-
-
Save OpenGrid/3251884 to your computer and use it in GitHub Desktop.
Revisions
-
OpenGrid revised this gist
Aug 3, 2012 . 1 changed file with 12 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,17 +2,16 @@ Check for validity of polish VAT ID number: NIP */ function NIPIsValid(nip) { var weights = [6, 5, 7, 2, 3, 4, 5, 6, 7]; nip = nip.replace(/[\s-]/g, ''); if (nip.length == 10 && parseInt(nip, 10) > 0) { var sum = 0; for(var i = 0; i < 9; i++){ sum += nip[i] * weights[i]; } return (sum % 11) == nip[9]; } return false; } -
OpenGrid revised this gist
Aug 3, 2012 . 1 changed file with 10 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,17 @@ /* Check for validity of polish VAT ID number: NIP */ function isNIPvalid(NIP) { var controlSum = 0, factors = [6, 5, 7, 2, 3, 4, 5, 6, 7]; NIP += ''; NIP = NIP.replace(/[^0-9]+/g,''); if(NIP.length < 10 || NIP.length > 10) return false; for(var c = 0; c <= 8; c++) { controlSum += parseInt(NIP.charAt(c)) * factors[c]; } if(controlSum % 11 == parseInt(NIP.charAt(9))) { return true; } return false; -
OpenGrid created this gist
Aug 3, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ function isNIPvalid(nip) { var controlSum = 0, factors = [6, 5, 7, 2, 3, 4, 5, 6, 7]; nip += ''; nip = nip.replace(/[^0-9]+/g,''); if(nip.length < 10 || nip.length > 10) return false; for(var c = 0; c <= 8; c++) { controlSum += parseInt(nip.charAt(c)) * factors[c]; } if(controlSum % 11 == parseInt(nip.charAt(9))) { return true; } return false; }