Skeuocard from Ken Keiter is a JS plugin that makes credit card information input a little more sane. With a slew of options including card provider requirements, and card validations, it's definitely worth a look. Also, check out the skeuocard-rails gem, if it pertains to your project.
MIT licensed. Source code on GitHub.