dist/validetta.js
function( tmp ) {
      if ( tmp.val === '' ) return true; // allow empty because empty check does by required metheod
      var reg, cardNumber, pos, digit, i, sub_total, sum = 0, strlen;
      reg = new RegExp( /[^0-9]+/g );
      cardNumber = tmp.val.replace( reg, '' );
      strlen = cardNumber.length;
      if( strlen < 13 ) return messages.creditCard;
      for( i=0 ; i < strlen ; i++ ) {
        pos = strlen - i;
        digit = parseInt( cardNumber.substring( pos - 1, pos ), 10 );
        if( i % 2 === 1 ) {
          sub_total = digit * 2 ;
          if( sub_total > 9 ) {
            sub_total = 1 + ( sub_total - 10 );
          }
        } else {
          sub_total = digit ;
        }
        sum += sub_total ;
      }
      if( sum > 0 && sum % 10 === 0 ) return true;
      return messages.creditCard;
    }
function( tmp ) {
      if ( tmp.val === '' ) return true; // allow empty because empty check does by required metheod
      var reg, cardNumber, pos, digit, i, sub_total, sum = 0, strlen;
      reg = new RegExp( /[^0-9]+/g );
      cardNumber = tmp.val.replace( reg, '' );
      strlen = cardNumber.length;
      if( strlen < 13 ) return messages.creditCard;
      for( i=0 ; i < strlen ; i++ ) {
        pos = strlen - i;
        digit = parseInt( cardNumber.substring( pos - 1, pos ), 10 );
        if( i % 2 === 1 ) {
          sub_total = digit * 2 ;
          if( sub_total > 9 ) {
            sub_total = 1 + ( sub_total - 10 );
          }
        } else {
          sub_total = digit ;
        }
        sum += sub_total ;
      }
      if( sum > 0 && sum % 10 === 0 ) return true;
      return messages.creditCard;
    }
function ( tmp ) { if ( tmp . val === '' ) return true ; // allow empty because empty check does by required metheod
 var reg , cardNumber , pos , digit , i , sub_total , sum = 0 , strlen ; reg = new RegExp ( / [^0-9]+ / g ) ; cardNumber = tmp . val . replace ( reg , '' ) ; strlen = cardNumber . length ; if ( strlen < 13 ) return messages . creditCard ; for ( i = 0 ; i < strlen ; i ++ ) { pos = strlen - i ; digit = parseInt ( cardNumber . substring ( pos - 1 , pos ) , 10 ) ; if ( i % 2 === 1 ) { sub_total = digit * 2 ; if ( sub_total > 9 ) { sub_total = 1 + ( sub_total - 10 ) ; } } else { sub_total = digit ; } sum += sub_total ; } if ( sum > 0 && sum % 10 === 0 ) return true ; return messages . creditCard ; }
Credit Card Control
@from : http://af-design.com/blog/2010/08/18/validating-credit-card-numbers
Credit Card Control