I just want to control a phone number input to the format 123-456-7890. I’ve tried ^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$ but I keep getting the invalid format error message.
Thanks,
Cynthia
I just want to control a phone number input to the format 123-456-7890. I’ve tried ^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$ but I keep getting the invalid format error message.
Thanks,
Cynthia
Hi,
I have always found getting regexes to work is a bit tricky. Between different programming languages and syntaxes, there are sometimes some character that I miss.
I checked your regex on regexr.com and it looks ok. Maybe check the code once again.
Here is an example that for checking numbers, that I use successfully:
data-rule-pattern="04[\d]{8}"
If you want to use it for validation, then remove the ^
from the front and $
from the end.
Sid,
Thanks for the help. That worked great!