[Solved] Email and mobile number validation on same html5 textbox with button


here is the simple javascript code which will validate both email and phone number.

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
function ValidateEmail(mail)   
{  
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;  
// if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.emailAddr.value))  
if(mail.match(mailformat))
  {  alert(mail);
    return (true)  
  }  
    alert("You have entered an invalid email address!")  
    return (false)  
}  

function validate()
{
var data=document.getElementById("email").value;
checkNumberorEmail();

}
function phonenumber(inputtxt)  
{  
  var phoneno = /^\d{10}$/;  
  if((inputtxt.match(phoneno)))  
        {  
        alert(inputtxt);
      return true;  
        }  
      else  
        {  
        alert("enter 10 digit number");  
        return false;  
        }  
}  


function checkNumberorEmail()
{
  var data=document.getElementById("email").value;
  if (isNaN(data)) 
  {
    ValidateEmail(data)   ;

  }
  else{
  phonenumber(data) 
  }
}
</script>
</head>
<body>

<form >

<input type="text" name="email" id="email">
<input type="button" onclick="validate()">
</form>
</body>
</html>

FIDDLE

solved Email and mobile number validation on same html5 textbox with button