Last active
October 13, 2022 17:47
-
-
Save Eomerx/9ee93dd6ea4d77cb2ac3 to your computer and use it in GitHub Desktop.
Revisions
-
Ömer Aslanbakan renamed this gist
Feb 26, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Ömer Aslanbakan created this gist
Feb 26, 2015 .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,24 @@ //======================================= // CHECK TC ID = //======================================= var checkTcNum = function(value) { value = value.toString(); var isEleven = /^[0-9]{11}$/.test(value); var totalX = 0; for (var i = 0; i < 10; i++) { totalX += Number(value.substr(i, 1)); } var isRuleX = totalX % 10 == value.substr(10,1); var totalY1 = 0; var totalY2 = 0; for (var i = 0; i < 10; i+=2) { totalY1 += Number(value.substr(i, 1)); } for (var i = 1; i < 10; i+=2) { totalY2 += Number(value.substr(i, 1)); } var isRuleY = ((totalY1 * 7) - totalY2) % 10 == value.substr(9,0); return isEleven && isRuleX && isRuleY; }; window.checkTcNum = checkTcNum; //-------- End of check tc id ---------//