Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to change this script to have a max character limit instead of a min?

I am working on a form in Unbounce and need the name fields to have a max character limit. I found this script in the Unbounce community but can’t seem to get the modifications to work for a max limit instead of a min. Can someone help me with what changes I need to make. Thanks!

<script>
  window.ub.form.customValidators.characterminlimit = {
    isValid: function(value) {
        return /^(?=.{50,})/.test(value);
    },
    message: 'Enter min 50 character',
  };
</script>

<script>
  window.ub.form.validationRules.first_name.characterminlimit = true;
</script>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

If for some reason you can’t get the length for the string value, you can try this regex /(^.{1,50}$)/ instead of the one you’re currently using. This will only match strings between 1 and 50 characters.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading