Is that Field Empty?
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).
For longest time, I had been doing it like this in JavaScript:
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:
theField.isNull
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).
This means that the following JavaScript expression checks whether a field’s value is empty:
(theField.isNull || theField.rawValue.length == 0)
And in FormCalc:
(theField.isNull | theField == "")
Comments
I have also used HasValue(theField) for FormCalc
Posted by: Karen | December 29, 2006 12:34 AM