Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <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>
Add Comment
Please, Sign In to add comment