diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 0671454..e4482b3 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -441,7 +441,7 @@ function system_element_info() { '#input' => TRUE, '#size' => 60, '#maxlength' => 128, - '#process' => array('ajax_process_form'), + '#process' => array('ajax_process_form', 'form_process_pattern'), '#theme' => 'password', '#theme_wrappers' => array('form_element'), ); diff --git a/core/modules/system/tests/form.test b/core/modules/system/tests/form.test index 5ec0434..0db2373 100644 --- a/core/modules/system/tests/form.test +++ b/core/modules/system/tests/form.test @@ -777,6 +777,7 @@ class FormValidationTestCase extends DrupalWebTestCase { function testPatternValidation() { $textfield_error = t('%name field is not in the right format.', array('%name' => 'One digit followed by lowercase letters')); $tel_error = t('%name field is not in the right format.', array('%name' => 'Everything except numbers')); + $password_error = t('%name field is not in the right format.', array('%name' => 'Password')); // Invalid textfield, valid tel. $edit = array( @@ -786,15 +787,18 @@ class FormValidationTestCase extends DrupalWebTestCase { $this->drupalPost('form-test/pattern', $edit, 'Submit'); $this->assertRaw($textfield_error); $this->assertNoRaw($tel_error); + $this->assertNoRaw($password_error); - // Valid textfield, invalid tel. + // Valid textfield, invalid tel, valid password. $edit = array( 'textfield' => '7seven', 'tel' => '818937', + 'password' => '0100110', ); $this->drupalPost('form-test/pattern', $edit, 'Submit'); $this->assertNoRaw($textfield_error); $this->assertRaw($tel_error); + $this->assertNoRaw($password_error); // Non required fields are not validated if empty. $edit = array( @@ -804,6 +808,16 @@ class FormValidationTestCase extends DrupalWebTestCase { $this->drupalPost('form-test/pattern', $edit, 'Submit'); $this->assertNoRaw($textfield_error); $this->assertNoRaw($tel_error); + $this->assertNoRaw($password_error); + + // Invalid password. + $edit = array( + 'password' => $this->randomName(), + ); + $this->drupalPost('form-test/password', $edit, 'Submit'); + $this->assertNoRaw($textfield_error); + $this->assertNoRaw($tel_error); + $this->assertRaw($password_error); // The pattern attribute overrides #pattern and is not validated on the // server side. diff --git a/core/modules/system/tests/modules/form_test/form_test.module b/core/modules/system/tests/modules/form_test/form_test.module index 9e98801..7d4e3be 100644 --- a/core/modules/system/tests/modules/form_test/form_test.module +++ b/core/modules/system/tests/modules/form_test/form_test.module @@ -539,6 +539,11 @@ function form_test_pattern_form($form, &$form_state) { '#title' => 'Everything except numbers', '#pattern' => '[^\d]*', ); + $form['password'] = array( + '#type' => 'password', + '#title' => 'Password', + '#pattern' => '[01]+', + ); $form['url'] = array( '#type' => 'url', '#title' => 'Client side validation',