Validating an Email Address in Drupal
Ran into a situation earlier today where I needed to validate a Drupal username and email address entered into a custom form that would create a Drupal 6 User account (see http://codekarate.com/content/create-user-account-drupal-6-programmatically for more information on the submit handler of the form). There are easy to use Drupal functions to validate the username and email addresses. See the examples below:
//check if this is a valid Drupal username user_validate_name('USERNAME'); //check if this is a valid email address user_validate_mail('test@test.com');
These two functions helped a lot in my validation handler and hopefully they can help you.



Discussions
test email domian
Are there any Drupal modules that allow you to test the domain of a potential registrant's email, and reject if it doesn't match a required domain?
I have a school district, and I only want to accept registrations for teachers in that school district. I want to be able to test the domain of the email (schooldistrict.org) for example, and if the email doesn't have that domain, I want to disregard the registration (though I would prefer to give the user the impression that their registration request is being considered even though it is disregarded).
Any suggestions?
Post new comment