Link to home
Start Free TrialLog in
Avatar of earwig75
earwig75

asked on

How can I allow 0, 10 or 13 digits only with regular expression/javascript

I am using the following to accept only 0 or 10 digits, but I need to change it to allow 0, 10 or 13. Can someone assist?

 if(/^(\d{0}|\d{10})$/.test(carCount) == false) {
......

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Add one more or check for 13 digits:

 if(/^(\d{0}|\d{10}|\d{13})$/.test(carCount) == false) {
....
}

Open in new window


That's it!