Skip to content

Javascript Validation for a phone number (Numbers, spaces, dots, hyphens)

So I have this validation for alphanumeric’s (/^[A-Za-z0-9,+-]+$/) however I want a validation for a phone number which only allows Numbers, Spaces, Dots and Hyphens. What code would I use to check for those.

Thanks Ben


According to my specifications its just Numbers, Spaces, Dots and Hyphens only. Thats any order and any length

That would be:

/^[0-9 .-]+$/