<?php $emailA = "john1@here.com"; $emailB = "john1@here#.com"; function validateEmail( $email ){ $regex = "/^[a-zA-Z0-9.]+@[a-zA-Z0-9.]+\.[a-zA-Z]{2,4}/"; $error = "\nOnly letters, numbers, dot and @ are allowed"; echo (preg_match($regex,$email))? "$email is valid\n" : "$error - $email is invalid\n"; return true; } validateEmail( $emailA ); validateEmail( $emailB );
You have javascript disabled. You will not be able to edit any code.