Created
May 10, 2013 17:25
-
-
Save shuizhongyueming/5555948 to your computer and use it in GitHub Desktop.
JavaScript: Util checkMail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* [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