JavaScript determines whether the user entered the correct email and phone format

  • 2020-03-30 00:47:27
  • OfStack

 
 
function form_check() { 
var email = document.getElementById("email").value; //Get email address
//Determine if the mailbox format is correct
if(!/^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$/.test(email)) { 
alert(" Mailbox format error !"); 
document.getElementById("email").focus(); //Let the mailbox text box get focus
return false; 
} 
return true; 
} 
 
function checkMobile(s) { 
var regu = /^[1][0-9][0-9]{9}$/; 
var re = new RegExp(regu); 
if (re.test(s)) { 
return true; 
} else { 
return false; 
} 
} 

Related articles: