Suppose there is a textbox with the field name 'Color' and you want its background colour to turn red when a user types in 'red' within a form design, you can use the drag and drop code editor to define a condition like below upon the 'onChange' event:
Here are the steps to understand how you can define such a condition:
1. From the left panel, go to the first option called 'Logic'. It will populate a list of logical blocks. Select the first 'if' block and drag it to the centre of the editor.
2. Click on the gear icon inside the 'if' block. It will populate the options available for the selected block.
3. Within the popup, drag and drop the else block just below the 'if' block as shown below.
4. Now, close the pop-up by clicking on the gear icon once again.
5. Go back to the left panel and select 'Logic'. Select the second block and drag it to the centre adjoining the 'if' block as shown below.
6. Go back to the left panel and select 'Custom Functions'. Select the second block 'Get Value' and drag it to the centre adjoining the first blank box opposite the 'if' block as shown below.
In the 'Select Control Name' dropdown, select 'Color'.
7. Go back to the left panel and select 'Text'. Select the first block and drag it to the centre, adjoining the second blank box opposite the 'if' block.
In the text box, enter the text 'red'.
8. Go back to the left panel and select 'Custom Functions'. Select the third block 'Setter' and drag it to the centre adjoining the 'do' block as shown below.
In the 'Select Control Name' dropdown, select 'Color'. Keep the 'Property Name' chosen as 'Background Color'. Click on the 'Value' box and in the colour picker that opens, select the red colour.
9. Go back to the left panel and select 'Custom Functions'. Select the third block 'Setter' and drag it to the centre adjoining the 'else' block as shown below.
In the 'Select Control Name' dropdown, select 'Color'. Keep the 'Property Name' chosen as 'Background Color'. Click on the 'Value' box, and in the colour picker that opens, keep the default white colour.
10. Once done, click 'OK' (at bottom right) to save the changes and exit the code editor, then save/publish the form design as needed. Once the form design is published and executed, the changes will be applicable to the new forms created under the related form type.
Next Article: Change background colour of a 'Dropdown' control based on the value selected by the user