Quantcast
Channel: Adobe Community: Message List - PDF Forms
Viewing all articles
Browse latest Browse all 57214

Re: String formula

$
0
0

In that case you shouldn't use the validation script shown above and do everything in the calculation. For example, if the result of the calculation can have 0 as a valid result, and you want to only show a result if both of the fields have a value, the custom calculation script could be:

 

// Custom calculation script

(function () {

 

    // Get the field values, as strings

    var s1 = getField("Text1").valueAsString;

    var s2 = getField("Text2").valueAsString;

 

    // Perform the calculation only if both fields have are non-blank

    if (s1 && s2) {

        event.value = +s1 - +s2;

    } else {

        event.value = "";

    }

 

})();

 

or more compactly:

 

(function () {

 

    var s1 = getField("Text1").valueAsString;

    var s2 = getField("Text2").valueAsString;

 

    event.value = s1 && s2 ? +s1 - +s2 : "";

 

})();


Viewing all articles
Browse latest Browse all 57214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>