Skip to content

Instantly share code, notes, and snippets.

@mishudark
Created February 4, 2011 01:18
Show Gist options
  • Select an option

  • Save mishudark/810570 to your computer and use it in GitHub Desktop.

Select an option

Save mishudark/810570 to your computer and use it in GitHub Desktop.
Validate user register o create
function inseguridad_form_user_register_alter(&$form, &$form_state) {
if(preg_match("/register|user\/create/",$_SERVER['REQUEST_URI']) ){
$form['#validate'][] = 'inseguridad_user_register_validate';
}
}
function inseguridad_user_register_validate($form, &$form_state){
$pass1 = $form['#parameters'][1]['post']['pass']['pass1'];
if( preg_match("/[^a-zA-Z0-9]/",$pass1))
form_set_error('inseguridad', t("La contraseña solo admite números y letras mayúsculas y minúsculas."));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment