monkeylee monkeylee - 4 months ago 16
jQuery Question

jquery validation regex for digits with hyphens

Can someone provide a regex that only allows digits and optionally hyphens

I have got as far as phone_number.match(/[0-9-]/); but with no luck

Answer

The following matches numbers interspersed with dashes, but not double dashes:

/^\d+(-\d+)*$/