Calling a Luhn check function when a credit card field changes
$(function() {
  // Always select a context and use it as the second parameter 
  // it will make everything far faster and less prone to errors
  var form = $('form'); 
  var stripCcNum = function(el) {
      return $(this).val().replace(/[^\d]/g, '');
  }

  $('input[name="payment\[cc_number\]"]', form).keyup(function() {

    setSelectValue(stripCcNum(this));

  }).blur(function(ccNum) {

    if (!luhnCheck( stripCcNum(this) )) {
        alert('Please enter a valid credit card number.');
    }

  });

});


Or for the totally and absolute 1337 (meaning you shouldn't do it for something this simple but it demonstrates some useful techniques)

$(function() {
  var form = $('form'),
    handleCcNum = function(doThis) {
      return function() { 
        doThis.call(this, $(this).val().replace(/[^\d]/g, ''));
      }
    }

  $('input[name="payment\[cc_number\]"]', form)
    .keyup( handleCcNum(function(num) { setSelectValue(num); } )
    .blur( handleCcNum(function(num) { 
       !luhnCheck(num) &amp;&amp; alert('Please enter a valid credit card number.');
    }));
});