0

Drupal seems to let users register with emails like xxx@yyy

I heard that this kind of email address can exist. But I want users to register with only emails like xxx@yyy.zzz

Is there any way to validate this type of email format and prevent users from registering with it?

2

There is a core function named: function valid_email_address that will check that the syntax is valid.

Example of use:

$mail = $form_state['values']['submitted_tree']['email_address'];
if (!valid_email_address($mail)) {
  form_set_error('[submitted][email_address]', t('The email address appears to be invalid.'));
}
  • Tanks I'll try that! – Sona7 Nov 7 '14 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.