TypeForm custom value validation using Regular Expressions

  • 18 August 2022
  • 5 replies
  • 1089 views

Hey, I have searched for this in the forum and found these:

Both provided solutions are some form of “what do you want to validate? let’s find some workarounds”, I find this a bit inadequate. Other platforms allow you to supply a custom regular expression which is used to validate the provided value. This offers a lot of flexibility, letting creators specify exactly what they want the field to contain.

I think this kind of validation should be offered in TypeForm. Regular expressions are a mature technology widely used since the beginning of the internet, and can be very useful for this purpose. I see a few ways this could happen:

  1. An additional setting in Short Text settings allowing you to provide a custom validation regular expression
  2. Support for regular expressions in Logic conditions, permitting loops back to the question if the value does not validate correctly
  3. A new value type which supports regular expressions

I hope this kind of feature is considered as some values feature detailed requirements, the available workarounds for which create awkwardness for the end-user.

 

Thnak you!


5 replies

Userlevel 7
Badge +5

Hi @JJRcop Happy Friday! I hope you had a great week. Thanks for sharing your feedback and opinions on this. I’ll share this with the product team. Do you mind sharing more about your use case and how you might use a feature like this for your forms/business? 😀

Hi @Liz, certainly! My primary use case is to validate a Discord ID, according to their username restrictions detailed here https://discord.com/developers/docs/resources/user#usernames-and-nicknames

Discord IDs feature the username, Bob#1234, and the discriminator, Bob#1234.

Using two fields, one for the username, and one for the discriminator, kinda works, except I can’t use a number field since leading zeroes are permitted, and the number field does not support leading zeroes. Additionally if I use a Short Text field for the discriminator to permit leading zeroes, I have to add an unimaginable amount of Logic conditions to make sure the field “does not conatain ‘a’, and, does not contain ‘b’, and, does not contain ...” and so on for every character that is not a number.

This regular expression I’ve developed covers most of the restrictions on usernames, and will only match those, at least accurately enough for my purposes assuming good faith on the submitter:

^[^@#:]{2,32}#\d{4}$

I would use this regular expression to try and match against an input provided in the form, then depending on how the feature is implemented, show an error or use Logic branching to redirect to a Statement which loops back to the input if the regex doesn’t match.

This is a lot simpler than other workarounds using multiple successive questions, because it already defines all of the rules I want in one go.

Userlevel 7
Badge +5

Hi @JJRcop Ok, thank you! This is great. I've shared this with the product team. 😀 If you think of anything else, let us know!

I would like this feature as well

I need this too

Reply