Return to Snippet

Revision: 13285
at April 17, 2009 13:29 by jonathanpglick


Initial Code
// form element
$form['email'] = array( 
  '#type' => 'textfield', 
  '#element_validate' => array('_valid_email'),
  '#required' => TRUE,
  '#default_value' => 'Enter your email address here',
);

// validation function
function _valid_email($element)
{	
	if ( !valid_email_address($element['#value']) ) {
		form_error($element, t('Please enter a valid email address'));
	}
}

Initial URL

                                

Initial Description

                                

Initial Title
Form validate email address

Initial Tags
drupal

Initial Language
PHP