Title: if else probleem
Last modified: August 22, 2016

---

# if else probleem

 *  Resolved [nono123](https://wordpress.org/support/users/nono123/)
 * (@nono123)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/if-else-probleem/)
 * I like to make a field with if and else, but i think i miss something here.
 * Somebody know what i am doing wrong?
 *  (function(){
 * if(fieldname24 < 10) return (“RTB houtpelletketel 10 kW”);
 * if(fieldname24 >= 10 && fieldname24 <= 16) return (“RTB houtpelletketel 16 kW”);
 * if(fieldname24 >= 16 && fieldname24 <= 30) return (“RTB houtpelletketel 30 kW”);
 * if(fieldname24 >= 30 && fieldname24 <= 50) return (“RTB houtpelletketel 50 kW”);
 * else return (“meer dan 50kW”);
 * })();
 * [https://wordpress.org/plugins/calculated-fields-form/](https://wordpress.org/plugins/calculated-fields-form/)

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

 *  Thread Starter [nono123](https://wordpress.org/support/users/nono123/)
 * (@nono123)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/if-else-probleem/#post-5208198)
 * I forgot to say, that there is NO output in the field.
 *  Thread Starter [nono123](https://wordpress.org/support/users/nono123/)
 * (@nono123)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/if-else-probleem/#post-5208213)
 * I got it finally working, but only with numbers.
    When i replays the number with
   text, there is no output anymore.
 * **Numbers are working:**
    (function(){ if(fieldname24 <= 0) return 0; if(fieldname24
   > 0 && fieldname24 <= 10) return 10; if(fieldname24 > 10 && fieldname24 <= 16)
   return 16; if(fieldname24 > 16 && fieldname24 <= 30) return 30; if(fieldname24
   > 30 && fieldname24 <= 50) return 50; else return 88; })()
 * **Text is not working:**
    (function(){ if(fieldname24 <= 0) return ‘text1’; if(
   fieldname24 > 0 && fieldname24 <= 10) return ‘text2’; if(fieldname24 > 10 && 
   fieldname24 <= 16) return ‘text3’; if(fieldname24 > 16 && fieldname24 <= 30) 
   return ‘text4’; if(fieldname24 > 30 && fieldname24 <= 50) return ‘text5’; else
   return ‘text6’;; })()
 * What do i do wrong ?
 *  Thread Starter [nono123](https://wordpress.org/support/users/nono123/)
 * (@nono123)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/if-else-probleem/#post-5208214)
 * I got it finally working, but only with numbers.
    When i replays the number with
   text, there is no output anymore.
 * **Numbers are working:**
    (function(){ if(fieldname24 <= 0) return 0; if(fieldname24
   > 0 && fieldname24 <= 10) return 10; if(fieldname24 > 10 && fieldname24 <= 16)
   return 16; if(fieldname24 > 16 && fieldname24 <= 30) return 30; if(fieldname24
   > 30 && fieldname24 <= 50) return 50; else return 88; })()
 * **Text is not working:**
    (function(){ if(fieldname24 <= 0) return ‘text1’; if(
   fieldname24 > 0 && fieldname24 <= 10) return ‘text2’; if(fieldname24 > 10 && 
   fieldname24 <= 16) return ‘text3’; if(fieldname24 > 16 && fieldname24 <= 30) 
   return ‘text4’; if(fieldname24 > 30 && fieldname24 <= 50) return ‘text5’; else
   return ‘text6’;; })()
 * What do i do wrong ?
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/if-else-probleem/#post-5208235)
 * Hi,
 * The issue is simple, the Calculated Field is implemented to display the results
   of the equations (numeric values), but if you want display other values, like
   text1, text2, …, you should modify the validation rules for the calculated fields.
 * Please, follow the steps below:
 * 1. Open the “module_public.js” file, located in “/wp-content/plugins/calculated-
   fields-form/js/modules/01_mathematical_logical/public/module_public.js”, with
   the text editor your choice.
 * 2. Go to the validation rule:
 * ‘validator’ : function( v )
    { return isFinite( v ) || /\d{2}[\/\-\.]\d{2}[\/\-\.]\
   d{4}/.test( v ); }
 * and modify it like follow:
 * ‘validator’ : function( v )
    { return isFinite( v ) || /\d{2}[\/\-\.]\d{2}[\/\-\.]\
   d{4}/.test( v ) || /text\d+/.test( v ); }
 * Best regards.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/if-else-probleem/#post-5208236)
 * Hi,
 * If you want accept any result, modify the validation like follow:
 * ‘validator’ : function( v )
    { return (typeof v != ‘undefined’); }
 * Best regards.
 *  Thread Starter [nono123](https://wordpress.org/support/users/nono123/)
 * (@nono123)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/if-else-probleem/#post-5208251)
 * YES
 * That was it.
 * Thanx you very much !!

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

The topic ‘if else probleem’ 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/)

 * 6 replies
 * 2 participants
 * Last reply from: [nono123](https://wordpress.org/support/users/nono123/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/if-else-probleem/#post-5208251)
 * Status: resolved