• Resolved dareko

    (@dareko)


    Hello, how can I detect that the “Number” field is empty / has no value?
    Standard validation tool displays the correct tooltip, but if the user refreshes the page (e.g. F5 button) the tooltip disappears and the whole calculation is computed using 0 (zero) value from that field.
    I’ve tried many different ways to arithmetically distinguish the entered zero from the empty field and unfortunately I found nothing.
    I can live with it, but I am trying to make the calkulator more “foolproof”.
    Thank you in advance for any advice.
    Darek

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @dareko

    Thank you very much for using our plugin. The plugin tries to get a number value to be used in calculations. If the field is empty, the plugin treas it as zero value. However, the plugin includes modifiers.
    For example, the “|r” modifier allows you to access the field’s raw value without preprocessing.

    I’ll try to describe the process with a hypothetical example. Assuming you have the equation:

    fieldname1*2

    If fieldname1 is empty, the equation’s result will be zero.

    However, assuming you want to return an empty string if the fieldname1 is empty.

    You can edit the equation as follows:

    IF(fieldname1|r == '', '', fieldname1*2)

    As you can see, I’m checking in the equation if the field’s raw value is empty.

    Best regards.

    Thread Starter dareko

    (@dareko)

    Thank you, this modifier is a great feature.
    It recognizes data “0.0”, but doesn’t recognize “0” – alone zero figure is treated in the same way as empty field.
    Any suggestions?

    Best Regards

    Plugin Author codepeople

    (@codepeople)

    Hello @dareko

    Please, use “===”

    IF(fieldname1|r === '', '', fieldname1*2)

    Best regards.

    Thread Starter dareko

    (@dareko)

    Great, it works!
    Thank you very much.

    And last question: what difference is between
    IF(fieldname1|r === ”, ”, fieldname1*2)
    and
    fieldname1|r===”?”:fieldname1*2

    Which one gives shorter code or shorter execution time?

    Kind Regards
    Darek

    Plugin Author codepeople

    (@codepeople)

    Hello @dareko

    One of your solutions uses the plugin operation IF and the second implementation, the ternary javascript operation. The ternary operator is the preferred alternative.

    Best regards.

    Thread Starter dareko

    (@dareko)

    Thank you,
    Have a nice weeknd.
    Darek

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to detect the empty Number field’ is closed to new replies.