View Full Version : how to have null value if another field is less than a certain number

07-05-2002, 12:17 AM
I'm coding a PDF form. I have a field that is not always filled in, but when it is, another (calculated) field shows that amount minus twenty. If no value is entered in the first field, -20 is now showing in the calculated field. I would like that calculated value to either show nothing or a zero if an amount less than 20 appears in the first field.

I've played around with the code and I'm completely stuck ... can anyone help me with this please? Thanks.

07-05-2002, 01:28 AM

well it also depends on how many calculations you have to do.
If you're concerned with only one field, you may just return the function that makes the calculcatiions earlier:

function myCalc(){
return ( isNaN( parseFloat(document.formName.fieldName.value) ) )? "":

basically, to check if a field holds a numerical value, aside from regular expressions which are not really neede for just merely numeric formats:

isNaN( parseFloat(VALUEHere) )

it returns true if it is NOT a number, false if it IS a number. You can craft your expressions accordingly.