Skip to content

Instantly share code, notes, and snippets.

@whalec
Created June 9, 2011 02:12
Show Gist options
  • Save whalec/1015901 to your computer and use it in GitHub Desktop.
Save whalec/1015901 to your computer and use it in GitHub Desktop.
Not tested. Probably doesn't even run. Hacked together jquery plugin. Now plus ninja tip
(function($) {
$.fn.credit_card = function(opts) {
this.opts = opts
this.change(function(){
var val = $(this).val()
if (val[0] == "4"){
$(opts.visa).addClass("highlighted");
return false;
}
var twodigit = val[0] + val[1];
if (twodigit == "34" || twodigit == "37") {
$(opts.amex).addClass("highlighted");
return false;
} else if (twodigit == "51") {
$(opts.mastercard).addClass("highlighted");
return false;
}
})
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment