PHP Classes

File: public/asset/vendor/jquery-validation/src/additional/creditcard.js

Recommend this page to a friend!
  Classes of fathurrahman   mnTemplate   public/asset/vendor/jquery-validation/src/additional/creditcard.js   Download  
File: public/asset/vendor/jquery-validation/src/additional/creditcard.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: mnTemplate
Route HTTP requests to callback functions
Author: By
Last change:
Date: 1 year ago
Size: 909 bytes
 

Contents

Class file image Download
// https://jqueryvalidation.org/creditcard-method/ // based on https://en.wikipedia.org/wiki/Luhn_algorithm $.validator.addMethod( "creditcard", function( value, element ) { if ( this.optional( element ) ) { return "dependency-mismatch"; } // Accept only spaces, digits and dashes if ( /[^0-9 \-]+/.test( value ) ) { return false; } var nCheck = 0, nDigit = 0, bEven = false, n, cDigit; value = value.replace( /\D/g, "" ); // Basing min and max length on // https://dev.ean.com/general-info/valid-card-types/ if ( value.length < 13 || value.length > 19 ) { return false; } for ( n = value.length - 1; n >= 0; n-- ) { cDigit = value.charAt( n ); nDigit = parseInt( cDigit, 10 ); if ( bEven ) { if ( ( nDigit *= 2 ) > 9 ) { nDigit -= 9; } } nCheck += nDigit; bEven = !bEven; } return ( nCheck % 10 ) === 0; }, "Please enter a valid credit card number." );