monkeylee monkeylee - 1 year ago 90
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 Source

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

/^\d+(-\d+)*$/
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download