Form validation using regex
Submitted by Kiran on Sun, 02/15/2009 - 11:10
Email validation regex and Function
This has always been my favorite function to validate email address at server side:
function validate_email($email) {
$result = TRUE;
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) {
$result = FALSE;
}
return $result;
}
$result = TRUE;
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) {
$result = FALSE;
}
return $result;
}
But soon i recover that it is not that perfect, any suggestion.
»
- 4 comments
- 1245 reads
Submitted by Kiran on Tue, 02/03/2009 - 16:12
Domain Validation
I have this regex -- /^([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/ which is not that effective.
Did any guy have a good tested regex for validating domain name.
»
- 3 comments
- 614 reads













