Created
June 30, 2011 00:10
-
-
Save maciejzgadzaj/1055327 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Implements hook_form_alter(). | |
| */ | |
| function MYMODULE_form_alter(&$form, &$form_state, $form_id) { | |
| if ($form_id == 'user_register_form') { | |
| $form['#validate'][] = 'MYMODULE_user_register_form_validate'; | |
| } | |
| } | |
| /** | |
| * Additional handler for user_register_form form validation. | |
| */ | |
| function MYMODULE_user_register_form_validate($form, &$form_state) { | |
| if (!preg_match('/^.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$/', $form_state['values']['pass'])) { | |
| form_set_error('pass', t('Password must be at least 10 characters and contain at least one lower case letter, one upper case letter, one digit and one special character.')); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment