A programmer’s job is to program computers. Not people.
The first UX rule for programmers: computers like being programmed; they were born for that. People, not so much.
If we give direct instructions or commands to users from the software (e.g., “Enter card number without dashes or spaces”), then we are trying to program people, which usually doesn’t end well.
When this happens, it’s best to go back to programming computers with the goal of making them adapt to people.
For example, use a regular expression to only accept numeric characters.
In pseudocode: find( /[^\d]/ ).replace("")
.
This instruction for the computer requires fewer characters than the instruction for the user, never fails, and makes everyone happy.
Everything works much better when we apply the tools we master to the domains they are meant for. Computers, we program. People, we understand.