how to create custom validation for text in matrix table side by side text boxes | XM Community
Skip to main content
Solved

how to create custom validation for text in matrix table side by side text boxes


Forum|alt.badge.img+3
  • Level 3 ●●●
  • 14 replies

Hi, I am looking for a way to add custom validation for two different text entry fields in a matrix table, one with a month range of 1-12 for month, and the second for year range of 1990s to 2000s. Is there a way to validate two separate text entry boxes?

Best answer by omkarkewat

Hi @four77 
You can implement the following custom validation.

 

 

1. Regex for Months (1-12):
^(1[0-2]|[1-9])$

Explanation:
^: Asserts the start of the string.
(1[0-2]|[1-9]): Matches a number between 1 and 12. The expression uses the | (OR) operator to allow either a single digit from 1 to 9 or a two-digit number starting with 1 followed by 0, 1, or 2.
$: Asserts the end of the string.


2. Regex for Years (1990s to 2000s):
^(199\d|200\d)$

Explanation:
^: Asserts the start of the string.
(199\d|200\d): Matches a year starting with either 199 and followed by any digit (\d) or starting with 200 and followed by any digit.
$: Asserts the end of the string.
NOTE: This will include years from 1990 to 2009.

 

View original

2 replies

Forum|alt.badge.img+20
  • QPN Level 5 ●●●●●
  • 290 replies
  • Answer
  • January 2, 2024

Hi @four77 
You can implement the following custom validation.

 

 

1. Regex for Months (1-12):
^(1[0-2]|[1-9])$

Explanation:
^: Asserts the start of the string.
(1[0-2]|[1-9]): Matches a number between 1 and 12. The expression uses the | (OR) operator to allow either a single digit from 1 to 9 or a two-digit number starting with 1 followed by 0, 1, or 2.
$: Asserts the end of the string.


2. Regex for Years (1990s to 2000s):
^(199\d|200\d)$

Explanation:
^: Asserts the start of the string.
(199\d|200\d): Matches a year starting with either 199 and followed by any digit (\d) or starting with 200 and followed by any digit.
$: Asserts the end of the string.
NOTE: This will include years from 1990 to 2009.

 


Forum|alt.badge.img+3
  • Author
  • Level 3 ●●●
  • 14 replies
  • January 2, 2024

Thanks, this worked perfectly


Leave a Reply