Skip to main content

I am using New Responsive Forms.  I have a business requirement to validate/mask a text field.  I am not sure if it would be easier to use a Text Mask or Regular Expression. Below are the requirements.  Can anyone help me with this?

  • Text Field called “Board Item No”
  • Format:
    • First part is limited to 2 digits (can be 1 digit)
    • Second part is limited to 4 digits (can be 1, 2, or 3 digits)
    • First and second parts are separated by a dash (-)
  • Example of valid values
    • 7-2
    • 23-2222
    • 1-123

 

 

 

 

 

Hi,

 

The text mask won’t work in this case because it doesn’t cater for the length of digits e.g. where you allow 1 or 2 digits before the dash.  A regular expression such as the below would do the trick though:

^\d{1,2}-\d{1,4}$

This one expects 1-2 digits then a dash then 1-4 digits.


@Chris_Ben  - Perfect.  Thank you!

 


Reply