Strip Non-numeric Characters from Phone Numbers

Whenever you capture a phone number on a form, wouldn't be nice to also capture a version of the number that can be used in a tel: link on a view?

Here's a jQuery snippet that will do just that and store the value stripped of non-numeric characters in a hidden field with the exception of the plus sign as used in a country code.

As an example, +1 123-456-7890 becomes +11234567890.

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *