Insert dashes between every fourth credit card number digit

Hello! I am customizing the Pro Sites Stripe credit card form and would like to know how I can create my Credit Card Number input so that it inserts a dash or space automatically between every fourth digit when entered. How is this done? Thank you