title: Make sure username is not a phone number
body: <p>I'm writing a mobile website and I would like the user to be able to login via username or phone number. I think the easist way to validate their response it to not allow them to signup using a phone number as their user name. </p>
  
  <p>The problem is that I'll need to check if the input of the username field is JUST a 10 or 11 digit number. This is where my inexperance in regex comes to my disadvantage. I'm hoping to try something like</p>
  
  <pre><code>    function do_reg($text, $regex)
  {
      if (preg_match($regex, $text)) {
          return TRUE;
      } 
      else {
          return FALSE;
      }
  }
  
       $username = $_POST['username'];
       if(do_reg($username, '[0-9]{10,11}')){
              die('cannot use a 10 or 11 digit number as a username');
       }
  </code></pre>
  
  <p>The above regex is matching all numbers that are 10-11 digits long. I think maybe I need a way to say if the ONLY thing in the user input field is a 10-11 digit number get mad otherwise release the butterflies and rainbows.</p>
  
  <p><strong>EDIT:</strong> For the record I decided to make sure the username wasn't JUST a number. Thought this would be simpler and I didn't like the idea of having people use numbers as logins.</p>
  
  <p>So I ended up with </p>
  
  <pre><code>if (!empty($username) &amp;&amp; preg_match('/^\d+$/', $username )) {
                die('username cannot be a number');
  }
  </code></pre>
  
  <p>Thanks for the help all.</p>