Posted By

jonathanpglick on 04/17/09


Tagged

drupal


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


Form validate email address


 / Published in: PHP
 

  1. // form element
  2. $form['email'] = array(
  3. '#type' => 'textfield',
  4. '#element_validate' => array('_valid_email'),
  5. '#required' => TRUE,
  6. '#default_value' => 'Enter your email address here',
  7. );
  8.  
  9. // validation function
  10. function _valid_email($element)
  11. {
  12. if ( !valid_email_address($element['#value']) ) {
  13. form_error($element, t('Please enter a valid email address'));
  14. }
  15. }

Report this snippet  

You need to login to post a comment.