How to add the Phone Input minimum & maximum length using a raw block?

Hello,

I have enabled the Phone field for the 'Create Account' and 'Edit Account' page.

Forms > Fields > System > Create Account > Phone.

Forms > Fields > System > Edit Account > Phone.

I would like users to enter a specific number of digits in that input, not more not less.

So, how to add the Phone Input minimum & maximum length (minlength & maxlength) using a raw block?

Thanks

  • 626
  • More
Replies (2)
    • Hello @LeonidS. Any idea? Thanks

      • Here we go! I've found the solution using a jQuery function and it works. I am sharing it.

        In the Page app > System > Sign Up > Settings > Injection, place the following code:

        <script>
        $(document).ready(function()
        {
          $("input[name=phone]").prop('minlength','12');
          $("input[name=phone]").prop('maxlength','12');
        });
        script>
        

        Please replace '12' with whatever value.

        Note: This code doesn't work if put in a raw block. It works in the page injection only.

        You can also use it with the Phone input on the 'Forgot Password' and 'Edit Account' page if you want.

        As you may have noticed, a similar function (option) already exists in the Phone field:

        Check for: Data Length (limit amount of characters: Min Value and Max Value)

        I couldn't use it as I will be using a Regular Expression for something else in the same field. Two functions cannot be used simultaneously in the 'Check for' field. One gets disabled automatically.

        Regards!

        Login or Join to comment.