--- authorcontact.module.orig 2009-01-05 23:50:51.000000000 +0000 +++ authorcontact.module 2009-06-08 14:46:28.000000000 +0000 @@ -54,6 +54,7 @@ '#title' => t('Email'), '#type' => 'textfield', '#required' => true, + '#element_validate' => array('authorcontact_form_validate') ); $form['sendercomment'] = array( '#title' => t('Comment'), @@ -75,11 +76,11 @@ /** * Validate the form */ -function authorcontact_form_validate($form_id, $form_values) { +function authorcontact_form_validate($element, $form_state) { //check the email address is valid - if(isset($form_values['email'])) { - if (!preg_match('/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,7})+$/', $form_values['email'])) { - form_set_error('email', t('Invalid email address')); + if(isset($form_state['values']['senderemail'])) { + if (!valid_email_address($form_state['values']['senderemail'])) { + form_set_error('email', t('The email address you entered is not valid')); } } }