Guest User

Untitled

a guest
Jul 16th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <script>
  2. require([
  3. 'jquery',
  4. 'jquery/ui',
  5. 'jquery/validate',
  6. 'mage/translate'
  7. ], function($){
  8. $.validator.addMethod(
  9. 'validate-customer-id-number', function(value) {
  10. var IDnum = String(value);
  11.  
  12. if ((IDnum.length>9) || (IDnum.length<5))
  13. return false;
  14. if (isNaN(IDnum))
  15. return false;
  16.  
  17. if (IDnum.length<9)
  18. {
  19. while (IDnum.length<9)
  20. {
  21. IDnum = '0' + IDnum;
  22. }
  23. }
  24.  
  25. var mone = 0, incNum;
  26. for (var i = 0; i < 9; i ++)
  27. {
  28. incNum = Number(IDnum.charAt(i));
  29. incNum *= (i % 2) + 1;
  30. if (incNum > 9)
  31. incNum -= 9;
  32. mone += incNum;
  33. }
  34. if (mone % 10 == 0)
  35. return true;
  36. else
  37. return false;
  38. }, $.mage.__('Enter Valid Id Number')
  39. )
  40. });
  41. </script>
Add Comment
Please, Sign In to add comment