Skip to content

Instantly share code, notes, and snippets.

@shuizhongyueming
Created May 10, 2013 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shuizhongyueming/5555948 to your computer and use it in GitHub Desktop.
Save shuizhongyueming/5555948 to your computer and use it in GitHub Desktop.
JavaScript: Util checkMail
/**
* [checkMail 验证用户输入的邮箱格式是否正确]
* @param {[string]} mailStr [已经去除两边空白的邮箱地址]
* @return {[int]} [0,合法;1,不合法]
*/
function checkMail(mailStr){//验证邮箱格式
if(mailStr.match(/^[\w-]+@[\w-]+((\.[\w-]{2,3}){1,2})$/gi)){return 0;}
else{return 1;}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment