How to validate whether an email address is in the correct format
This code will explain how to validate an email address and then accept it for processing/using. If you find this code useful, please vote for me.
AI
AI 摘要: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
源代码
<PRE> <font size=2 face=verdana,arial,helvetica> <? // Author : Joel Agnel $address = "[email protected]"; //The email address that is to validated $expression = "^[_A-Za-z0-9-]+@[_A-Za-z-]+(\.[A-Za-z]+)(\.[A-Za-z]+)*$"; //The expression that describes //the pattern the address should have if(!ereg("$expression",$address)) { //if $address is not matching to $expression echo "Sorry wrong address"; // not valid } else { // else it is valid echo "The address is valid"; } ?> <a href="mailto:[email protected]">Email me</a> for any help with this code </PRE>
原始评论 (3)
从 Wayback Machine 恢复