I've been looking all over (various forums and tutorials, etc.) and trying to find something that can work. Couple of things first:
• I'm very new to javascript (and all languages really), but learned a little just for this.
• I'm using these javascripts inside validation, calculation and formatting of form fields inside of Adobe Acrobat.
Here's what I'm trying to do: Create a form where users input certain whole numbers into several fields: FieldA, FieldB, FieldC, FieldD, FieldE, FieldF, FieldG, FieldH, FieldI.
Here's how it goes:
• Fields A, B, C, D, F, G - user inputs whole integer.
• FieldE = (FieldD)/3
• FieldH = (FieldG)/(FieldF)
• FieldI = FieldA+FieldB+FieldC+FieldE+FieldH
I'm having trouble with displaying/calculating "0" and "NaN". Instead of dealing with the headache trying to explain to several users what NaN is and why a "0" is there, it's easier to have them not displayed (hidden). On the user end, they won't care if there is no info displayed in any given form field, as long as there aren't a bunch of "0"s or "NaN"s littered throughout the forms. So, the simple solution is: How do I write code to not only detect 0, null, and/or NaN ... but also ... display nothing in any given form field, in these cases. If there is a whole number (in some cases Math.floor implemented for a very specific purpose), then display it.
So, I'm looking for a solution to:
• Keep a form field empty, when 0, Nan, or null is the case.
• Disregard these things in calculations, when this is the case.
• Any actual whole number interger is the only thing to display (even if it is a negative).
Any suggestions?
UPDATE 6/10/2015: This is how I wrote the code.... what am I doing wrong?
{
If ("FieldE" != null && !isNaN("FieldE") &&"FieldE" != 0)
{
//calculate for FieldE
}
else
{
// set FieldE = ""
{
}