PHP Classes

File: vendors/parsleyjs/src/extra/validator/luhn.js

Recommend this page to a friend!
  Classes of Jorge Castro   Gentelella BladeOne   vendors/parsleyjs/src/extra/validator/luhn.js   Download  
File: vendors/parsleyjs/src/extra/validator/luhn.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Gentelella BladeOne
Render templates using Bootstrap for presentation
Author: By
Last change:
Date: 3 years ago
Size: 738 bytes
 

Contents

Class file image Download
// luhn extra validators window.ParsleyConfig = window.ParsleyConfig || {}; window.ParsleyConfig.validators = window.ParsleyConfig.validators || {}; window.ParsleyConfig.validators.luhn = { fn: function (value) { value = value.replace(/[ -]/g, ''); var digit; var n; var _j; var _len1; var _ref2; var sum = 0; _ref2 = value.split('').reverse(); for (n = _j = 0, _len1 = _ref2.length; _j < _len1; n = ++_j) { digit = _ref2[n]; digit = +digit; if (n % 2) { digit *= 2; if (digit < 10) { sum += digit; } else { sum += digit - 9; } } else { sum += digit; } } return sum % 10 === 0; }, priority: 32 };