• Resolved Tobias

    (@gestaltraeume)


    Hi

    I need to set the follow code to a text value based on a number:

    (function(){
    if(fieldname4==’1′) return ‘Liter’;
    if(fieldname4==’2′) return ‘m3’;
    if(fieldname4==’3′) return ‘kg’;
    if(fieldname4==’4′) return ‘Ster’;
    if(fieldname4==’5′) return ‘kg’;
    });

    How can i get that?

    I read the Text in a solution and put a javascript into module_public.js:
    return isFinite( v ) || /\d{2}[\/\-\.]\d{2}[\/\-\.]\d{4}/.test( v ) || /Liter|m3|kg|Ster/i.test( v );

    But it doesn′t work!

    https://www.markus-heizkessel.de/umrechnung-neu/

    Thank′s for help!

    Best regards.

    https://www.ads-software.com/plugins/calculated-fields-form/

Viewing 3 replies - 1 through 3 (of 3 total)
  • This should help you – it is from this page: https://www.ads-software.com/support/topic/change-date-format-16?replies=13

    “…Now, you should open the “module_public.js” file, located in “/wp-content/plugins/calculated-fields-form/js/modules/01_mathematical_logical/public/module_public.js”, in the text editor your choice, and modify the snippet of code:

    ‘validator’ : function( v )
    {
    return isFinite( v ) || /\d{2}[\/\-\.]\d{2}[\/\-\.]\d{4}/.test( v );
    }

    like follow:

    ‘validator’ : function( v )
    {
    return typeof v != ‘undefined’;
    }

    …”

    Plugin Author codepeople

    (@codepeople)

    Hi,

    Thanks Vivanco, you are right. The instructions were included in the FAQ of plugin.

    Best regards.

    Thread Starter Tobias

    (@gestaltraeume)

    Hi codepeople and vivanvo!

    Thank′s a lot for the fast answer.

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘code to a text value based on a number’ is closed to new replies.