-2

I am trying to validate user input, entered in a text box, adheres to the following requirement, using regular expression:

The 3-digit number range that is acceptable is 002-899

I have never used regular expressions and thus am turning to any more knowledgeable folks in this forum for assistance.

1

I'm with Cognito Forms support. You can accomplish your goal by using a custom mask and a custom error message. I have instructions for you below:

  1. In the format validation drop-down, select Custom Mask.
  2. In the format mask textbox, enter ###. This will make sure that the input only allows 3 numbers.
  3. Make sure you put a message in the Format Error Message text box. Otherwise, the custom mask won't work.
  4. Under Show Custom Error at the bottom of the field's settings, select When.
  5. When the editor pops open, switch it over to the advanced editor.
  6. Enter in the following calculation, where you replace "Numbers" with the name of your field. The trick here is to convert the text to a number and compare the value to your range.

    =(Int32.Parse(Numbers)< 2) or (Int32.Parse(Numbers)>899)

  7. Make sure you enter in a custom error message or your validation won't trigger.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.