Validates as a phone number
I am trying to validate a string as a phone number (digits and certain special characters). I used a existing code snippet from here: http://snippets.dzone.com/posts/show/597 which seems to be correct. But everytime `string.match(format)` returns `null`, which causes to show the error message.


    var format = /^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/;
    var string = jQuery(".validate_phone").val();
    if (string.match(format) != true) {
      // some error message
    }

I checked already, `string` is filled which the expected value.

What is wrong with this code? Thanks in advance!
Validates as a phone number
===

I am trying to validate a string as a phone number (digits and certain special characters). I used a existing code snippet from here: http://snippets.dzone.com/posts/show/597 which seems to be correct. But everytime `string.match(format)` returns `null`, which causes to show the error message.


    var format = /^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/;
    var string = jQuery(".validate_phone").val();
    if (string.match(format) != true) {
      // some error message
    }

I checked already, `string` is filled which the expected value.

What is wrong with this code? Thanks in advance!