Validating a credit card number is one thing. But getting it properly formatted is a whole separate issue which can be handled using the Inputmask plugin.
But note this plugin is not just a CC number mask. It supports literally anything you’d like to mask including phone numbers or zip codes. You can even pass custom regex codes to mask whatever format you want.
Inputmask pairs nicely with the CC validator plugin since these two can turn a simple input field into a dynamite CC billing form.