Categories: Microsoft Forms Pro
* IMPORTANT *
EFFECTIVE: 2020-21-07 – Microsoft announced that Forms Pro was becoming Dynamics 365 Customer Voice. While elements of this blog post may still be accurate, keep in mind that the product has change. You can review the blogs in the D635 Customer Voice category which is being added to over time.
*** NOTE: ALL INFORMATION IS ACCURATE AT DATE OF PUBLISHING ***

We recently looked at using the Restrictions option on a Text field in Forms Pro, which gives us the option to set it as an Email address. This provides validation checking to make sure the value entered by the respondent is correct. What if you have other fields like this? We have an option in restrictions that lets us set a custom validation. Let’s look at how to do this.

First, add your text field. Next, click on the ellipsis (three dots) and click on Restrictions.

From there, select Custom. We are going to request an Account Number from the respondent.

In order to add in your custom validation, you need to know and understand how to write regex, or regular expressions. I am not that great at it, but luckily for me, I have a smart brother I could ask. πŸ˜‰ So thanks, Owen Rumney! So, for this example, the Account Number in question is 3 capital letters, a hyphen, then four numbers. The regex to use for this is [A-Z]{3}-\d{4}. A field with a validation message is added, with the text ‘Enter value in the specified format’.

You can type something else in that validation field, something that will make sense to the respondent if they enter it incorrectly. Add a subtitle to the question, and this will then be displayed under the question for the respondent.

If we now fill out the survey, when typing into the field, we see the validation message we added. This will provide an example of what the value should look like.

Finally, if the respondent attempts to submit the survey without matching the expression used in the custom restriction on the field, they will see a message at the bottom of the form indicating the question that needs reviewing and adjusting.

Want to just watch how to do this? Check out the video: https://youtu.be/LeJ9sBfzVOI


Check out the latest post:
Auto Assign Leads Without Code Using Lead Scoring & Work Assignment


This is just 1 of 477 articles. You can browse through all of them by going to the main blog page, or navigate through different categories to find more content you are interested in. You can also subscribe and get new blog posts emailed to you directly.




7 thoughts on “Custom Regex Validation In Forms Pro

  1. It’s worth saying there is probably no regex in the world that someone has not written in the past – so don’t be scared.

    Use google to search for what you want and then test it at any of the the numerous websites that allow you to edit and test them I personally like https://regexr.com/ which also explains what is going on.

    And if you really want to learn how they work use https://www.regular-expressions.info/ which is the basis of the O’Reilly cookbook on Regex.

  2. Why I enter \d{10} for user fill answer only 10 digit but not work bcoz user can fill >= 10 digit then submit is done.

    What’s my wrong?

    1. Hi Charkkrit, looks like you will need something a little different. My expression was showing that you needed AT LEAST a certain number and did not stop at that number. So use this expression instead:
      ^[0-9]{10}?$
      It will make sure the user has submitted EXACTLY 10 digits in to that field.

Comments are closed for this post.