Last active
July 16, 2018 06:47
-
-
Save itaymesh/3b89f4e40f241efbbe93481d5ee6fbce to your computer and use it in GitHub Desktop.
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 characters
<script> | |
require([ | |
'jquery', | |
'jquery/ui', | |
'jquery/validate', | |
'mage/translate' | |
], function($){ | |
$.validator.addMethod( | |
'validate-customer-id-number', function(value) { | |
var IDnum = String(value); | |
if ((IDnum.length>9) || (IDnum.length<5)) | |
return false; | |
if (isNaN(IDnum)) | |
return false; | |
if (IDnum.length<9) | |
{ | |
while (IDnum.length<9) | |
{ | |
IDnum = '0' + IDnum; | |
} | |
} | |
var mone = 0, incNum; | |
for (var i = 0; i < 9; i ++) | |
{ | |
incNum = Number(IDnum.charAt(i)); | |
incNum *= (i % 2) + 1; | |
if (incNum > 9) | |
incNum -= 9; | |
mone += incNum; | |
} | |
if (mone % 10 == 0) | |
return true; | |
else | |
return false; | |
}, $.mage.__('Enter Valid Id Number') | |
) | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment