title: javascript validation phone number
body: <p>alright, whats wrong with my script, JShint is throwing three lines of red code saying i have issues in my variable and my if/else statement. I am trying to validate if the phone number is a valid USA phone format</p>
  
  <pre><code>    $( "#phone" ).focusout(function telephone() {
      if( this.value === "" || this.value === null ) {
          $( "#error_messages" ).text("");
          return false;
      } else {
          var re = \d{3}[\-]\d{3}[\-]\d{4};
          if(re.test(document.getElementById("phone").value)) {
              $( "#error_messages" ).text("");
              return true;
          } else {
              $( "#error_messages" ).text("Phone Number* not a valid format xxx-xxx-xxxx");
              return false;
          }
      }
  });
  </code></pre>