pagelets/nodejitsu/creditcard/base.js
function number(event) {
    var element = event.element
      , value = element.value
      , key = this.digit(event)
      , valid;

    //
    // Input must be numerical.
    //
    if (!key.allowed && event.type !== 'blur') return;

    //
    // Always format if the event is of type blur. This will ensure the input
    // box does not stay red on blur if formatted value is valid.
    //
    if (event.type === 'blur') this.number.set('value', this.lib.format(value));

    //
    // Check if the number is valid.
    //
    if (value.replace(/\D/g, '').length >= 16 || key.removal) {
      valid = this.lib.validate(value);

      //
      // Show card type or hide if invalid.
      //
      this.card[valid ? 'removeClass' : 'addClass']('gone');
      this.card.find('strong').set('innerHTML', this.lib.cardscheme(value));

      if (this.validate) {
        //
        // Check against testnumbers in production mode. Valid should be checked
        // as well, otherwise an incomplete credit card number would be valid.
        //
        if (this.production) {
          valid = valid && !~this.lib.testnumbers.indexOf(+value.replace(/\D/g, ''));
        }

        //
        // Update the styling of the input.
        //
        this.number.set('className', valid ? 'valid' : 'invalid');
      }
    }

    //
    // Add spaces for each block of 4 characters.
    //
    this.number.set('value', this.lib.format(value));
  }
function number(event) {
    var element = event.element
      , value = element.value
      , key = this.digit(event)
      , valid;

    //
    // Input must be numerical.
    //
    if (!key.allowed && event.type !== 'blur') return;

    //
    // Always format if the event is of type blur. This will ensure the input
    // box does not stay red on blur if formatted value is valid.
    //
    if (event.type === 'blur') this.number.set('value', this.lib.format(value));

    //
    // Check if the number is valid.
    //
    if (value.replace(/\D/g, '').length >= 16 || key.removal) {
      valid = this.lib.validate(value);

      //
      // Show card type or hide if invalid.
      //
      this.card[valid ? 'removeClass' : 'addClass']('gone');
      this.card.find('strong').set('innerHTML', this.lib.cardscheme(value));

      if (this.validate) {
        //
        // Check against testnumbers in production mode. Valid should be checked
        // as well, otherwise an incomplete credit card number would be valid.
        //
        if (this.production) {
          valid = valid && !~this.lib.testnumbers.indexOf(+value.replace(/\D/g, ''));
        }

        //
        // Update the styling of the input.
        //
        this.number.set('className', valid ? 'valid' : 'invalid');
      }
    }

    //
    // Add spaces for each block of 4 characters.
    //
    this.number.set('value', this.lib.format(value));
  }
function number ( event ) { var element = event . element , value = element . value , key = this . digit ( event ) , valid ; // // Input must be numerical. // if ( ! key . allowed && event . type !== 'blur' ) return ; // // Always format if the event is of type blur. This will ensure the input // box does not stay red on blur if formatted value is valid. // if ( event . type === 'blur' ) this . number . set ( 'value' , this . lib . format ( value ) ) ; // // Check if the number is valid. // if ( value . replace ( / \D / g , '' ) . length >= 16 || key . removal ) { valid = this . lib . validate ( value ) ; // // Show card type or hide if invalid. // this . card [ valid ? 'removeClass' : 'addClass' ] ( 'gone' ) ; this . card . find ( 'strong' ) . set ( 'innerHTML' , this . lib . cardscheme ( value ) ) ; if ( this . validate ) { // // Check against testnumbers in production mode. Valid should be checked // as well, otherwise an incomplete credit card number would be valid. // if ( this . production ) { valid = valid && ! ~ this . lib . testnumbers . indexOf ( + value . replace ( / \D / g , '' ) ) ; } // // Update the styling of the input. // this . number . set ( 'className' , valid ? 'valid' : 'invalid' ) ; } } // // Add spaces for each block of 4 characters. // this . number . set ( 'value' , this . lib . format ( value ) ) ; }
On credit card number changes, add spaces and check validaty.

@param {Event} event
@api private
On credit card number changes add spaces and check validaty .