Hi @campbelllansw
Try this
^>0-9]{6,12}$
^ : Start anchor
d0-9] : Character class to match one of the 10 digits
{6,12} : Range quantifier. Minimum 6 repetition and maximum 12.
$ : End anchor
Garret, thank you so much this worked perfectly. Much appreciate.
I have one more validation issue I am trying to resolve:
In the text box I need the prefix to show in field “C-” and then the user can enter min 5 max 6 characters (digits and/or characters.
E.g. C-12345 C-123456 C-TN1234 C-Q1234
Hope someone can help?!
Try this
^[Cc]-[0-9]{6,12}$
^ : Start anchor
>Cc] : Character class to match either Uppercase or Lowercase C
- : Match hyphen character
e0-9] : Character class to match one of the 10 digits
{6,12} : Range quantifier. Minimum 6 repetition and maximum 12.
$ : End anchor
I really appreciate you help, but after the “C- this can be characters, e.g., TN and or digits, 12345
So C-TN1234 or C-A12345 or C-123456
Let me clarify
First two Char is “C-”
Next is 5-6 characters which can consist of
- TN and 3-4 digits → TN123, TN1234
- 1 alphabet lA-Z] and 4-5 digits
- 5-6 digits
or did you want next 5-6 any combination of alphabets and digits
Yes, they must always prefix with C- then the next 5 or 6 can be a combination of characters or numbers, E.g. C-TN1234 or C-123456 or C-12345 or C-A1234
Thanks
Hey @campbelllansw
First two Char is “C-”
Next is 5-6 characters which can consist of
- TN and 3-4 digits → TN123, TN1234
- or 1 alphabet aA-Z] and 4-5 digits
- or 5-6 digits
^/Cc]-(TN\d{3,4}|NA-Za-z]\d{4,5}|\d{5,6})$
First two Char is “C-”
next 5-6 any combination of alphabets and digits
^iCc]-(.{5,6})$
Fixed. Prefix is C-
^C-.{5,6}$
Thank you so much Garrett….that has worked exactly as needed….very much appreciate you help and your quick response.
Garret, can I ask for one more solution
Is there any way to set the Pattern based on the choice of another fitler:
For example:
I have a choice field “Area Code”
If the user selects 02,03,04,05,06,06,08,09 then the length on the Telephone field is set to max 8 digits.
If the user select INTL then the Telephone field max digits is 15.
I looked at the rules but could not see any actions there that would set the rule?
Thanks
Is there a way to tweak this formula to enforce exactly five characters in a single-line-of-text field? I already have a rule that enforces the value be numeric, as well as column setting to enforce a max of 5 characters, but I need to force the user to enter a minimum of five characters as well (it’s for a zip code). Also, where is this formula to be used? Control settings? Rule on the control? Javascript?
Is there a way to tweak this formula to enforce exactly five characters in a single-line-of-text field? I already have a rule that enforces the value be numeric, as well as column setting to enforce a max of 5 characters, but I need to force the user to enter a minimum of five characters as well (it’s for a zip code). Also, where is this formula to be used? Control settings? Rule on the control? Javascript?
You use it in the field controls under the validation tab, you can select Yes under “Use Regular Expression”. Then you can enter a regular expression that has to match whatever the users have to fill out. If you want to enforce exactly five characters, either letters or numbers, you can use ^\w{5}$. \w is the code for letters or numbers, and curlybraces detail how many. If you want five digits (numbers 0 to 9) you can use \d instead of \w. ^ details the start of the string, so it shouldn’t have anything else preceding it, and $ denotes the end of the string, meaning it shouldn’t have anything after it. Some examples:
- ^\w{5}$ matches exactly five characters, either letters or numbers like aBcde or q5ef3 or 12345 but not 124tew
- ^\d{5}$ matches a five digit number, for instance 00000 or 12456 but not a532g
- ^ia-z]{5}$ matches five lowercase letters, for instance abcde or aaaaa but not ALOv1 or FAahg
- ^iA-Z]{5}$ matches five uppercase letters, for instance ABCDE or AAAAA but not aaaaa or AA341 or ABCDEF
You use it in the field controls under the validation tab, you can select Yes under “Use Regular Expression”. Then you can enter a regular expression that has to match whatever the users have to fill out. If you want to enforce exactly five characters, either letters or numbers, you can use ^\w{5}$. \w is the code for letters or numbers, and curlybraces detail how many. If you want five digits (numbers 0 to 9) you can use \d instead of \w. ^ details the start of the string, so it shouldn’t have anything else preceding it, and $ denotes the end of the string, meaning it shouldn’t have anything after it. Some examples:
- ^\w{5}$ matches exactly five characters, either letters or numbers like aBcde or q5ef3 or 12345 but not 124tew
- ^\d{5}$ matches a five digit number, for instance 00000 or 12456 but not a532g
- ^matches five lowercase letters, for instance abcde or aaaaa but not ALOv1 or FAahg
- ^ matches five uppercase letters, for instance ABCDE or AAAAA but not aaaaa or AA341 or ABCDEF
Awesome! I didn’t think it was that simple. Much appreciated!