How can I modify a regular expression to validate additional phone number formats using JavaScript?

Based on my experience doing javascript validate phone number implementations for apps that had messy user input, it’s smart to anticipate slight variations.

Here’s an even more flexible version:

/^\(?\d{3}\)?[-\s]?\d{3}[-\s]?\d{4}$|^\d{10}$|^\d{3}[-\s]?\d{3}[-\s]?\d{4}$/

What’s new here? This not only allows clean (123) 456-7890, 123-456-7890, and 1234567890, but it also accepts slight mixes — like numbers separated by just spaces or just hyphens — without breaking validation. It’s a bit more forgiving, making your javascript validate phone number feature feel much smarter and user-friendly.