Answers.Body: <p>Ok, I found an example on the Civi Wiki and, with a bit of workaround, it finally works: </p>
  
  <pre><code>function joomla_civicrm_validateForm($formName, &amp;$fields, &amp;$files, &amp;$form, &amp;$errors) {  
  
    $errors = array();
  
    // check we're targeting the right form
    if ($formName == 'Edit') {
      return true;
    }
  
     $password = CRM_Utils_Array::value( 'cms_pass', $fields );
  
     // ensure that password is present and valid
     if (!$password) {
        $errors['cms_pass'] = ts( 'Password is a required field' );
     } elseif (strlen($password) &lt; 50) {
        $errors['cms_pass'] = ts( 'Password must be longer than 50 characters');
     }
  
    return empty($errors) ? true : $errors;
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-11T15:00:49.693Z
Answers.LastActivityDate: 2018-12-11T17:37:33.523Z
Answers.LastEditDate: 2018-12-11T17:37:33.523Z
Answers.UserDisplayName: Ictadmin
Body: <p>I'm working on a version of CiviCRM installed in Joomla, I'm using a registration form with custom fields of Civi for the registration.
  The problem is that CiviCRM does not apply the same checks on passwords as Joomla does.
  I have not found solutions in the system, so I'm trying to insert custom controls using hooks.
  As indicated I created a file and specified the path and customize the code find on CiviCRM guide for my purpose, but does not detect any changes on the form I'm using. </p>
  
  <pre><code>function joomla_civicrm_validateForm( $formName, &amp;$fields, &amp;$files, &amp;$form, &amp;$errors ) {
    if ($formName == 'Edit') {
      foreach ($fields['cms_pass'] as $key =&gt; $password) {
        if(strlen(trim($password)) &gt; 8) {
          $errors['cms_pass[' . $key . ']'] = ts('Password must be 8 characters');
        }
      }
    }
    return;
  }
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-29T14:56:44.070Z
Comments.Text: CiviCRM uses the CMS for managing users and passwords so it is not managing passwords separately from Joomla.  Can you explain a bit more about your form, how it is being called and where it appears Civi is not checking the password?
Comments.UserDisplayName: Aidan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-30T11:59:19.230Z
Comments.Text: Hello. I am using the form "Name and adress" (default in CIVI) with "Account creation required " active, but, the password field don't do any of the Joomla control
Comments.UserDisplayName: Ictadmin
Tags: <forms><gdpr>
Title: CiviCRM password length in Joomla
ThreadText: # CiviCRM password length in Joomla
  
  (Asked by: username_0 on 2018-11-29)
  
  I'm working on a version of CiviCRM installed in Joomla, I'm using a registration form with custom fields of Civi for the registration.
  The problem is that CiviCRM does not apply the same checks on passwords as Joomla does.
  I have not found solutions in the system, so I'm trying to insert custom controls using hooks.
  As indicated I created a file and specified the path and customize the code find on CiviCRM guide for my purpose, but does not detect any changes on the form I'm using.
  
  ```
  function joomla_civicrm_validateForm( $formName, &$fields, &$files, &$form, &$errors ) {
    if ($formName == 'Edit') {
      foreach ($fields['cms_pass'] as $key => $password) {
        if(strlen(trim($password)) > 8) {
          $errors['cms_pass[' . $key . ']'] = ts('Password must be 8 characters');
        }
      }
    }
    return;
  }
  
  ```
  
  **Tags:** forms, gdpr
  
  > **Comments:**
  > **username_1**: CiviCRM uses the CMS for managing users and passwords so it is not managing passwords separately from Joomla.  Can you explain a bit more about your form, how it is being called and where it appears Civi is not checking the password?  
  > **username_0**: Hello. I am using the form "Name and adress" (default in CIVI) with "Account creation required " active, but, the password field don't do any of the Joomla control  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-12-11. Score: 1 | Accepted answer
  
  Ok, I found an example on the Civi Wiki and, with a bit of workaround, it finally works:
  
  ```
  function joomla_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {  
  
    $errors = array();
  
    // check we're targeting the right form
    if ($formName == 'Edit') {
      return true;
    }
  
     $password = CRM_Utils_Array::value( 'cms_pass', $fields );
  
     // ensure that password is present and valid
     if (!$password) {
        $errors['cms_pass'] = ts( 'Password is a required field' );
     } elseif (strlen($password) < 50) {
        $errors['cms_pass'] = ts( 'Password must be longer than 50 characters');
     }
  
    return empty($errors) ? true : $errors;
  }
  
  ```
  
  
  ---
  
  