Title: Help Adding Rules
Last modified: February 21, 2025

---

# Help Adding Rules

 *  Resolved [pexel](https://wordpress.org/support/users/pexel/)
 * (@pexel)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/help-adding-rules/)
 * Hi;
 * My inflation calculation formula is currently working correctly, but I would 
   like to account for situations where the “End Month” and “End Year” selected 
   by the user are after the current date.
 * For example, if the calculated date is January 2025, and the user selects July
   2025, I want the formula to use the inflation data for January 2025 and display
   a warning message. The warning message should be as follows:
 * _“Since inflation data has not been released yet, inflation data for January 
   2025 has been used for the calculation.”_
 * In this way, if the selected end date is in the future, the calculation will 
   proceed with the data for the nearest available month and year, while also informing
   the user that the data hasn’t been released yet.
   Formdata:How can we add a rule
   for this situation? I have the following field values:
 *     ```wp-block-code
               const formData = {            baslangicYil: fieldname21|r,            baslangicAy: fieldname20|r,            bitisYil: fieldname3|r,            bitisAy: fieldname2|r,            malSepeti: fieldname26        };
       ```
   
 * Thank you

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

 *  Plugin Author [CodePeople2](https://wordpress.org/support/users/codepeople2/)
 * (@codepeople2)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/help-adding-rules/#post-18319933)
 * Hello [@pexel](https://wordpress.org/support/users/pexel/)
 * I’m sorry, I don’t know how you implemented your equations or use the formData
   constant in them. However, if you want to compare the date entered by the user
   with today, assuming the date field in the form is fieldname123, you can use 
   the following piece of code as part of the equation:
 *     ```wp-block-code
       if( TODAY() < DATEOBJ(fieldname123) ) {/* The code to use when the fieldname123 date is in future */} else {/* The code to use when the fieldname123 date is in the past or today */}
       ```
   
 * Best regards.
 *  Thread Starter [pexel](https://wordpress.org/support/users/pexel/)
 * (@pexel)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/help-adding-rules/#post-18319949)
 *     ```wp-block-code
       (function() {    var kriter1 = "";    var kriter2 = "";    var kriter3 = "";    var kriter4 = "";    var kriter5 = "";           (function () {        const formData = {            baslangicYil: fieldname21|r,            baslangicAy: fieldname20|r,            bitisYil: fieldname3|r,            bitisAy: fieldname2|r,            malSepeti: fieldname26        };        I am retrieving the data externally here.                                         kriter1 = data.yeniSepetDeger;                kriter2 = data.toplamYil || data.toplamAy;                kriter3 = data.ilkYilTufe;                kriter4 = data.sonYilTufe;				kriter5 = data.toplamDegisim;                                // Update the HTML elements with the new values                jQuery('#calculation-kriter1').html(kriter1);                jQuery('#calculation-kriter2').html(kriter2);                jQuery('#calculation-kriter3').html(kriter3);                jQuery('#calculation-kriter4').html(kriter4);				jQuery('#calculation-kriter5').html(kriter5);                // Optionally, update labels for better display                jQuery('.kriter1-aciklama').html('Yeni Sepet Değeri: ');                jQuery('.kriter1-sonuc').html(FORMAT(PREC(kriter1, 2, true), {groupingsymbol:".", decimalsymbol:","}) + ' TL');;                jQuery('.kriter2-aciklama').html('Toplam Yıl: ');                jQuery('.kriter2-sonuc').html(kriter2+' Yıl');                jQuery('.kriter3-aciklama').html(fieldname21|v + ' Yılı ' + fieldname20|v + ' Ayındaki TÜFE: ');                jQuery('.kriter3-sonuc').html(kriter3);                jQuery('.kriter4-aciklama').html(fieldname3|v + ' Yılı ' + fieldname2|v + ' Ayındaki TÜFE: ');                jQuery('.kriter4-sonuc').html(kriter4);				jQuery('.kriter5-aciklama').html('Enflasyon Oranı: ');                jQuery('.kriter5-sonuc').html('%' + kriter5);            },        });    })();    return { kriter1, kriter2, kriter3, kriter4, kriter5 }; })();
       ```
   
 * This is my code. How can I add the rule to it?
 *  Plugin Author [CodePeople2](https://wordpress.org/support/users/codepeople2/)
 * (@codepeople2)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/help-adding-rules/#post-18320017)
 * Hello [@pexel](https://wordpress.org/support/users/pexel/)
 * I’m sorry, but I don’t understand by the code what do you want to do.
 * However, if you want to display a message when the user selects a future date
   and you have a tag with a class like you did with the other elements on your 
   form (E.g. `<div class="show-message-here"></div>`) and the date field is the
   fieldname123.
 * Your equation code would be similar to:
 *     ```wp-block-code
       (function() {    var kriter1 = "";    var kriter2 = "";    var kriter3 = "";    var kriter4 = "";    var kriter5 = "";           if( TODAY() < DATEOBJ(fieldname123) ) {      jQuery('.show-message-here').html('Your text here');    } else {      jQuery('.show-message-here').html('');    }        (function () {        const formData = {            baslangicYil: fieldname21|r,            baslangicAy: fieldname20|r,            bitisYil: fieldname3|r,            bitisAy: fieldname2|r,            malSepeti: fieldname26        };                kriter1 = data.yeniSepetDeger;                kriter2 = data.toplamYil || data.toplamAy;                kriter3 = data.ilkYilTufe;                kriter4 = data.sonYilTufe;				kriter5 = data.toplamDegisim;                                // Update the HTML elements with the new values                jQuery('#calculation-kriter1').html(kriter1);                jQuery('#calculation-kriter2').html(kriter2);                jQuery('#calculation-kriter3').html(kriter3);                jQuery('#calculation-kriter4').html(kriter4);				jQuery('#calculation-kriter5').html(kriter5);                // Optionally, update labels for better display                jQuery('.kriter1-aciklama').html('Yeni Sepet Değeri: ');                jQuery('.kriter1-sonuc').html(FORMAT(PREC(kriter1, 2, true), {groupingsymbol:".", decimalsymbol:","}) + ' TL');;                jQuery('.kriter2-aciklama').html('Toplam Yıl: ');                jQuery('.kriter2-sonuc').html(kriter2+' Yıl');                jQuery('.kriter3-aciklama').html(fieldname21|v + ' Yılı ' + fieldname20|v + ' Ayındaki TÜFE: ');                jQuery('.kriter3-sonuc').html(kriter3);                jQuery('.kriter4-aciklama').html(fieldname3|v + ' Yılı ' + fieldname2|v + ' Ayındaki TÜFE: ');                jQuery('.kriter4-sonuc').html(kriter4);				jQuery('.kriter5-aciklama').html('Enflasyon Oranı: ');                jQuery('.kriter5-sonuc').html('%' + kriter5);            },        });    })();    return { kriter1, kriter2, kriter3, kriter4, kriter5 }; })();
       ```
   
 * Best regards.

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

The topic ‘Help Adding Rules’ 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: [CodePeople2](https://wordpress.org/support/users/codepeople2/)
 * Last activity: [1 year, 3 months ago](https://wordpress.org/support/topic/help-adding-rules/#post-18320017)
 * Status: resolved