AngularJS : email or phone number validation
<p><strong>Expectation :</strong></p>

<p>I am working on login form in Angular. Users can login with <strong>Email/Phone</strong>. I need to validate the Email/Phone in single text-box.</p>

<p><strong>Live Scenario :</strong></p>

<p>Facebook implemented same type of functionality in login. we can login in Facebook via <strong>Email/Phone</strong>. But as per the research Facebook validates the user data by performing server side validations not the client side validations.</p>

<p><strong>Tried so far :</strong></p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function validate() {
  var textBoxValue = document.getElementById('emailphone').value;
  var emailPattern = /^[a-z][a-zA-Z0-9_]*(\.[a-zA-Z][a-zA-Z0-9_]*)?@[a-z][a-zA-Z-0-9]*\.[a-z]+(\.[a-z]+)?$/; 
  if(textBoxValue == '') {
    alert('Please enter value');
    return false;
  } else if(isNaN(textBoxValue)) {
    if(!(textBoxValue.match(emailPattern))) {
      alert('Please enter valid email');
      return false;
    }
  } else {
    if(textBoxValue.length != 10) {
      alert('Please enter valid phno');
      return false;
    }
  }
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input type="text" name="emailphone" id="emailphone"/&gt;
&lt;input type="submit" value="Validate" onclick="validate()"&gt;</code></pre>
</div>
</div>
</p>

<p>I am able to achieve this functionality using pure JavaScript but I want to implement it in Angular using <strong><code>ng-pattern</code></strong> or if there is any work around in Angular.</p>

<p><strong>I found this post on SO but not working as per my expectation</strong>.</p>

<p><a href="https://stackoverflow.com/questions/32776182/validation-for-email-or-phone-number-for-same-text-field-in-angularjs">Validation for email or phone number for same text field in angularjs</a></p>