The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript credit card input Re: credit card input


Are you using jQuery? If so you can use this plugin:

If you are not using jQuery it might be worth using just for this reason.

You might need to do a check based on what card they chose which would look something like this (not tested)

if ( $('#card_type_dropdown').change(function () {
if ( $(this).val() == 'amex' )
else { $("#credit").mask("9999-9999-9999-9999"); }

**Note: ** I don’t really know if .mask supports live change events, but using something with this plugin might be the easiest / quickest option.

Hopefully that helps you a little bit.