Home >Backend Development >PHP Tutorial >Determine whether the string emailAddr is a legal email format_PHP tutorial

Determine whether the string emailAddr is a legal email format_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:21:341319browse

/**
* Determine whether the string emailAddr is a legal email format
* Mainly determine whether @ and . appear, and their positions
* @param emailAddr The entered email address
* @return true/ false.
*/

function emailCheck(emailAddr)
{
if((emailAddr == null) || (emailAddr.length < 2)) return false ;

// @ must appear and not be the first character.
var aPos = emailAddr.indexOf("@" ,1) ;

if(aPos < 0)
{
return false ;
}

// Appears after @, and does not follow immediately.
if(emailAddr.indexOf("." ,aPos+2) < 0)
{
return false ;
}

return true ;
}


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532434.htmlTechArticle/** * Determine whether the string emailAddr is a legal email format* Mainly determine whether @ and . appear, and The position of both * @param emailAddr The entered email address * @return true/false. *...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn