The form field validation trick they don’t want you to know
Yes, that was a purposefully click-bait headline.
One of the most frustrating things for users is unclear or unintuitive form constraints. My personal pet peeve are phone number, credit card, or SSN/ EIN fields which ask for numeric-only entry. While it may very well be necessary that your field use only numeric data, you don’t have to offload that requirement to the user. If, for instance, your field collects a North American telephone number, you know that a valid telephone number consists of 10 numeric characters. Instead of offloading the numerics-only constraint to the user, you can easily and simply strip the non-numeric characters yourself before then validating the string length. This seems far more intelligent and certainly more user-friendly.
Because so many things require string manipulation most, if not all, programming languages have some mechanism of finding, substituting, or removing sub-strings, often through the use of Regular Expressions. Here are some examples, shamelessly stolen from Code Codex:
I’m available for accessibility consulting, audits, VPATs, training, and accessible web development, email me directly at email@example.com or call me at +1 443-875-7343