Title: Conditional Formatting
Last modified: December 14, 2023

---

# Conditional Formatting

 *  Resolved [michaelrieder](https://wordpress.org/support/users/michaelrieder/)
 * (@michaelrieder)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/conditional-formatting-13/)
 * Hi CodePeople
 * is it possible to format field2 (e.g. set background to red) if field1 is empty.
 * Best Regards Michael
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fconditional-formatting-13%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/conditional-formatting-13/#post-17278837)
 * Hello [@michaelrieder](https://wordpress.org/support/users/michaelrieder/)
 * You can use a calculated field as an auxiliary to modify other background fields
   at runtime.
 * Insert a calculated field in the form (you can hide it by ticking a checkbox 
   in its settings) and enter an equation similar to the following one:
 *     ```wp-block-code
       (function(){
       let color = IF(fieldname1|r == '', 'red', 'white');
       getField(fieldname1|n).jQueryRef().css('background', color);
       })()
       ```
   
 * If you want to modify the background color of the input tag in the field instead
   of the field as a whole, the code would be:
 *     ```wp-block-code
       (function(){
       let color = IF(fieldname1|r == '', 'red', 'white');
       getField(fieldname1|n).jQueryRef().find(':input').css('background', color);
       })()
       ```
   
 * Best regards.
 *  Thread Starter [michaelrieder](https://wordpress.org/support/users/michaelrieder/)
 * (@michaelrieder)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/conditional-formatting-13/#post-17279998)
 * Thank you very much, it works! Just one last question: What means |n and |r
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/conditional-formatting-13/#post-17280050)
 * Hello [@michaelrieder](https://wordpress.org/support/users/michaelrieder/),
 * The plugin replaces the fields’ names with their values in the equations evaluation
   process. The |n (Ex. fieldname1|n) tells the plugin you are referring to the 
   field’s name directly instead of its value. Also, the plugin preprocesses the
   fields’ values to extract numbers (when possible) to use in the mathematical 
   operations. The |r (Ex fieldname1|r) tells the plugin you want to use the raw
   field’s value without preprocessing.
 * Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Conditional Formatting’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [2 years, 5 months ago](https://wordpress.org/support/topic/conditional-formatting-13/#post-17280050)
 * Status: resolved