As a form designer, you can be almost certain that there will be a time when you’ll need to check a field to see whether its value is empty (whether the form filler has specified a value).
if (theField.rawValue == null || theField.rawValue.length == 0) // field is empty else // field has been filled
That served me quite well until yesterday when I found myself needing to do the same, but this time in FormCalc. Theoretically, the following should’ve worked:
if (theField == null | theField == "") then // field is empty else // field has been filled endif
But for some reason, the FormCalc interpreter was giving me a hard time with the null keyword (maybe it’s because I don’t use it very often and it was upset at me, I don’t know — if you’re a developer, you’ll understand that sometimes, code can have feelings and a mind of its own ) so was forced to try and find some other way to check if a field’s value is null in FormCalc and I found one:
The isNull property (of the XFA Scripting Model’s node object) “indicates whether the current data value is the null value”, as stated on page 422 of the Adobe XML Form Object Model Reference (located in the XML section).
(theField.isNull || theField.rawValue.length == 0)
And in FormCalc:
(theField.isNull | theField == "")
Posted by Stefan Cameron on May 19th, 2006
Filed under Scripting
Both comments and pings are currently closed.