Please Enter Your Credit Card Number with No Spaces

The Problem

One of the easiest ways for e-commerce websites to make my life more difficult is to require me to enter my credit card number with no spaces. It’s much easier for me to ensure that my card number is correct by looking at a number formatted like this:

1234 1234 1234 12341

rather than this:


Why It’s Bad

First, it’s easier to compare four four-digit numbers against my physical card. Second, it’s much easier to see if I’ve accidentally missed a digit:

1234 123 1234 1234

The Solution

This can be fixed in a number of ways.

The best approach is to probably allow spaces1 in credit card input fields in the browser and strip them out on the server side. This is likely a 1-line code change.

An alternate would be to handle this on the client-side (in the browser). When the action button/link is clicked, Javascript could strip out spaces from the input field, so that the data submitted to the web server has no spaces. The downside to this approach is that the user would see the spaces disappear from the credit card number when the form is submitted1.