vendor: 909 bytes, lines 1-40
1// https://jqueryvalidation.org/creditcard-method/ 2// based on https://en.wikipedia.org/wiki/Luhn_algorithm 3$.validator.addMethod( "creditcard", function( value, element ) { 4 if ( this.optional( element ) ) { 5 return "dependency-mismatch"; 6 } 7 8 // Accept only spaces, digits and dashes 9 if ( /[^0-9 \-]+/.test( value ) ) { 10 return false; 11 } 12 13 var nCheck = 0, 14 nDigit = 0, 15 bEven = false, 16 n, cDigit; 17 18 value = value.replace( /\D/g, "" ); 19 20 // Basing min and max length on 21 // https://dev.ean.com/general-info/valid-card-types/ 22 if ( value.length < 13 || value.length > 19 ) { 23 return false; 24 } 25 26 for ( n = value.length - 1; n >= 0; n-- ) { 27 cDigit = value.charAt( n ); 28 nDigit = parseInt( cDigit, 10 ); 29 if ( bEven ) { 30 if ( ( nDigit *= 2 ) > 9 ) { 31 nDigit -= 9; 32 } 33 } 34 35 nCheck += nDigit; 36 bEven = !bEven; 37 } 38 39 return ( nCheck % 10 ) === 0; 40}, "Please enter a valid credit card number." );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.