Increase min length of customer activate account and reset password

Topic summary

A user asks how to increase the minimum password length from 5 to 12 characters for customer account activation and password reset pages, noting they cannot find relevant settings in Shopify or the theme’s liquid files.

Two solutions are proposed:

  1. JavaScript validation approach: Add custom JavaScript to theme.liquid that targets password input fields and enforces a 12-character minimum using setCustomValidity(). This requires jQuery to be included in the theme.

  2. HTML pattern validation (recommended): Directly modify the password input elements in main-activate-account.liquid and main-reset-password.liquid files by adding HTML5 attributes: pattern="regex" and title="error message". This method provides native browser validation without requiring additional JavaScript libraries.

A detailed guide is referenced on the Helium Dev blog for implementing strong password validation on Shopify customer account activation pages. The original poster confirms the solutions are helpful.

Summarized with AI on November 10. AI used: claude-sonnet-4-5-20250929.

Hello!

Is it possible to increase the min. length from 5 to 12 for customer account passwords (account/activate & account/reset)? I can’t find any settings or a way to set it in the theme liquid files.

Kind regards,

Julian

@Julian87 Add the following JavaScript code to your theme.liquid file.

document.addEventListener('DOMContentLoaded', function() {
  var passwordInput = document.querySelector('input[type="password"]');

  if (passwordInput) {
    passwordInput.addEventListener('input', function() {
      var minLength = 12;

      if (passwordInput.value.length < minLength) {
        passwordInput.setCustomValidity('Password must be at least ' + minLength + ' characters long.');
      } else {
        passwordInput.setCustomValidity('');
      }
    });
  }
});

This code will enforce a minimum password length of 12 characters on any input field with the type “password” on your site.

Make sure that you have the following line of code in your theme.liquid file to include jQuery in your theme.

{{ '//ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js' | script_tag }}

Hey there! You can do this by adding regular expression validation directly to the HTML input element.

You will need to find the password and password confirmation input elements which are usually located in the main-activate-account.liquid and main-reset-password.liquid files. Then add the HTML attributes pattern=“regex” and title=“Your error message”. Here’s an example of this:


  
   

  
  

Hopefully that helps you out! You can also read a little more details about this in the guide on our blog here: https://heliumdev.com/blog/shopify-strong-passwords-customer-account-activation-page

1 Like

thank it’s a very helpful solution and clear description thank you very much