Forums

Setting up validation for 10-digit US phone number

sixdeuces 22 Oct, 2020
I've got a very simple contact form set up. I'm trying to use regex to validate a 10-digit US phone number in the format: 555-555-5555

I entered my regex into the regex field: ^[0-9]{3}\-[0-9]{3}\-[0-9]{4}$

Now, when using the form the field turns red as expected when typing, then back to white once the number is correctly filled.
However, when pressing submit, the validation fails and the error message is displayed to enter the number in the correct format.

What gives? I assume I have missed some option in the validation panel.

[file=13398]Untitled-1.jpg[/file]
sixdeuces 23 Oct, 2020
1 Likes
"Redo all your forms" isn't really the answer I was hoping for.

In any case, I was able to sort it out on my own.

The solution was two part:
  1. Use leading and trailing frontslashes on the regex, like: /^[0-9]{3}\-[0-9]{3}\-[0-9]{4}$/
  2. In the Setting tab, make sure the form is set to the V6.1 type
Hopefully that helps someone in the future.
Max_admin 24 Oct, 2020
I was saying just rebuild this form!🙂
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
You need to login to be able to post a reply.