Created
June 9, 2011 02:12
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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