Skip to content

Instantly share code, notes, and snippets.

@akahn
Created January 7, 2009 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akahn/44372 to your computer and use it in GitHub Desktop.
Save akahn/44372 to your computer and use it in GitHub Desktop.
/**
* Zips must be 5-digit integers and email addresses must be valid.
*/
function email_zip_validate($form, &$form_state) {
if (!is_numeric((int)$form_state['values']['zip']) || strlen($form_state['values']['zip']) != 5) {
form_set_error('zip', t('The zip code you entered was not valid. Please try entering it again.'));
}
if (!valid_email_address($form_state['values']['email'])) {
form_set_error('email', t('The email address you entered was not valid. Please try entering it again.'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment