Checklist Guide

A Phone Field That Accepts Spaces, Dashes and Parentheses

Short answer

Let a patient type a phone number the way they write it, with spaces, dashes or parentheses. Use a telephone field, do not force one format, clean the number after the form is sent, and show a plain example under the label so nobody is rejected for punctuation.

By Gio LaRocheUpdated 5 min read
Get my free auditor call (561) 291-2681

The number that gets bounced

A new patient types their number as (561) 555-0100 and the form answers with an error: please enter a valid phone number. They try again with dashes, then without anything, and by the third try some of them close the page. The number was correct every time. The form simply expected only one way of writing it.

This is a quiet leak on a contact or booking page. A patient who gave up never calls and never appears in your inquiry log. It is cheap to fix, because the cause is usually one setting in the form.

What MDN says about telephone fields

MDN's reference for the telephone input says the value is not automatically checked against any format, because telephone formats vary worldwide. The only built-in check is required, which marks an empty field as invalid. A pattern can be added to demand a specific shape, and MDN's own example accepts 865-555-6502 but rejects 41-323-421.

MDN also warns that a single validation rule for phone numbers is impractical. Requirements should be set per site, and a pattern such as three digits, three digits, four digits is useful only for certain locales. It adds that checking in the page is no substitute for checking on the server, since people can alter the page or send data directly.

The W3C's forms tutorial makes a matching point. Validation should accept different input formats, and it gives the example of a number-only field causing trouble for postal codes that contain letters. A phone number typed with spaces or parentheses is the same kind of case.

What to ask your web company to do

  1. 1Use the telephone field type, so phones can show a number keypad. MDN says mobile browsers may present a keypad optimized for phone numbers.
  2. 2Remove any pattern that allows only digits and dashes. If a pattern stays, it must allow spaces, parentheses, dashes and dots.
  3. 3Do not cut the field off at ten characters. A number written with punctuation is longer than ten.
  4. 4After the form is sent, strip the punctuation on the server and store clean digits, so your office list stays tidy.
  5. 5Show a plain example under the label, such as 561 555 0100, so patients know any style is welcome.
How a patient types itWhat the form should do
(561) 555-0100Accept it
561-555-0100Accept it
561 555 0100Accept it
5615550100Accept it
555-0100Ask for the area code, in words, and say why

When a number really is wrong

A form should still catch a number that cannot work, such as one with too few digits. Do it in words, naming the field and what is missing, as our guide to form error messages explains. A good message says Please add your area code, not Invalid input. Keep the visible label above the box too, as in visible labels above every field.

Test it yourself

Open your contact form and type the same number five ways, using the table above. If any style is refused, send the list to whoever maintains the form. Then try it on a phone to confirm the number keypad appears. The related settings for names and addresses are in our guide to autofill and phone keyboard settings. This is practical guidance, not legal advice.

Frequently asked questions

Should a phone field allow only digits?

No. Patients type spaces, dashes and parentheses out of habit. Accept them, then strip the punctuation after the form is sent. Rejecting a correct number because of punctuation costs you a person who was trying to reach you.

Does a telephone field check the number?

Not by default. MDN says phone formats vary worldwide, so the field only blocks an empty entry when it is marked required. Any format rule has to be added on purpose, and it should stay loose.

Why check on the server as well?

MDN notes that a check in the page is no substitute for a check on the server, since people can alter the page or send data directly. The server step also cleans the number for your records.

What about patients outside the United States?

A strict pattern that expects ten digits will reject them. Keep the rule loose or let the number through with a country code, and let the office confirm it when it calls back.

Should I show an example number?

Yes, a short one under the label, such as 561 555 0100, tells patients any style is welcome. Use a made-up sample, never a real patient's number, and keep it as visible text, not only placeholder text.

Sources

Keep reading

Ready to Grow Your Practice?

Primara is now accepting new independent practices nationwide. Most new engagements begin within one week.

Send Us a Message

We respond within one business day.

* Required field

We'll call to confirm your consultation.

No spam, ever. HIPAA-aware agency. We respond within one business day. For urgent inquiries, call (561) 291-2681.

Founder-LedHIPAA-AwareServing Practices Nationwide