I forgot to say, that there is NO output in the field.
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 ?
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 ?
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.
Hi,
If you want accept any result, modify the validation like follow:
‘validator’ : function( v )
{
return (typeof v != ‘undefined’);
}
Best regards.