We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36461
    • 102 Posts
    Hello,

    I’m trying to find out how to make eForm check a field for character count.

    I need at least 8 numbers entered in this field, before form gets validated.

    I’ve tried with RANGE, but it’s not right.

    I failed to find any information on this in documentation.

    <label for="phone">Phone</label>
    <input name="phone" size="40" type="text" class="field" eform="phone:integer:1:At least 8: #RANGE 8" /> 
    
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Range doesn’t do that; it allows the field to be within a certain range of numeric values (such as anything between 1 and 10)
      # #RANGE - a comma separated list of numbers or numeric ranges. When setting a range the order is not important. 1~10 or 10~1 will both validate a number between 1 and 10 (inclusive). Handles negative as well as positive numbers
      example: #RANGE 1,3,-5~-15,60~82
      You’ll need to use #FUNCTION or #REGEX.

      Using #REGEX should look something like this (although I have no more than a passing acquaintance with regular expressions!)
      #REGEX /\d{8}/
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 36461
        • 102 Posts
        Thank you!

        This worked perfectly smiley