Reputation: 155
I would like to test if the right phone number was enterred in the text field. The phone number should be ddd-ddddddd which means 3digits then must have "-" and then 7 digits. How do I set the regular expression for that ? Thanks :)
Upvotes: 0
Views: 9469
Reputation: 28894
var phoneNumber = '123-1234567';
if(phoneNumber.match(/^\d{3}-\d{7}$/))
{
alert('blah');
}
Upvotes: 2