I have two text boxes which compares the value in one text box with other. Assume Text Box 1 has value as 1234 and Text Box 2 has value 12345,123,12346.

Now I will be graying out the text box 1 by applying rule as If Text Box 2 contains Text Box 1 then do conditional formatting of graying out. In this scenario Textbox 2 doesn't contain the value of Text Box 1 how ever the condition turns out to be true and then greys out. Its takes 123 which is present in text box 2 and as it finds relative match with 123(neglecting 4) it is returning true.

Text Box 2 value is obtained by concatenating several text box values with commas. I want to perform exact match and grey out if it contains. Is there a way I can grey out the text box 1 by comparing the value in text box 2 before and after comma of each value in textbox.

Here is what I am trying to avoid enter image description here enter image description here

As we see I entered 1234 in Text Box 1 in fact this value is not present in Text Box 2 however it stills grey out.

1 Answer 1


You can use following expression

enter image description here

contains(concat(my:field2, ","), concat(my:field1, ","))

I have tested following use cases

  1. Field2 = "1,12,123,1234"
    • Field = "1"
    • Field = "12"
    • Field = "123"
    • Field = "1234"
  • Hashim, I have one question since I already have the concatenated string stored in textbox2. I was trying to put something like this in expression --> contains(my:field2) but its not working. Reason I am asking is I have around 80 controls which means I need to put This expression of concatenation in all of the controls. Commented Dec 22, 2014 at 22:40
  • There is no concept of global rules. You need to apply rules on individual text box controls. Commented Dec 22, 2014 at 22:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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