Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Eddie Drew 2 posts 92 karma points
    Nov 10, 2022 @ 15:46
    Eddie Drew
    0

    New User, need help with field validation

    Hi all,

    I have taken over from someone in the business and have a field with the following validation - ^[0-15]*$, i can see this is numerical and 15 characters acceptable. However, I now need to make this 15 characters to accept both text and numbers...

    Help?!!?

    Thanks in advance

  • Chris Norwood 131 posts 642 karma points
    Nov 10, 2022 @ 17:27
    Chris Norwood
    1

    Hi!

    The expression:

    ^[0-15]*$
    

    Is a regular expression (I assume this is on an Umbraco Forms field?) - you can test these here:

    https://www.regextester.com/

    The expression I think you might want for what you're trying to do is:

    ^[0-15]*[a-z]*[A-Z]*$
    

    However, as it stands it looks like this would only let you input 0, 1 or 5 (as well as any letter), so you'd probably want something more like:

    ^[0-9]*[a-z]*[A-Z]*$
    

    Which will let you input any number at all, and doesn't restrict the length or how big the number is; if you need to restrict the length to 15 characters the expression would be:

    (?=^.{0,15}$)(^[0-9]*[a-z]*[A-Z]*$)
    

    Regular expressions are....kind of arcane and complicated, but they can be pretty powerful :).

  • Eddie Drew 2 posts 92 karma points
    Nov 11, 2022 @ 09:20
    Eddie Drew
    100

    Hi Chris, thanks a lot... saved me a bit of pain while I am trying to get up to speed with things on here!

    I have it working! thanks so much....

Please Sign in or register to post replies

Write your reply to:

Draft