Thanks George. I am changing fields from to/from readonly based on logic because some fields are required, others are not, and some are "N/A" and I wanted to be sure the users could not fill-in the "N/A" form fields.
I think my dirty logic in the Calculation event just needs to be:
bFormDirty = bFormDirty || (event.value != this.getField(event.target.name);
where bFormDirty is a document-level variable.
Oh no ! checkboxes do not have a Calculate event handler.
I'll have to use "OnBlur". But wait !! I am already using it for some of the fields.....and I cannot build onto any embedded code because of the lack of a "getAction" method !!!
Woe is me once again.
That won't work. You're comparing event.value (which is something you're supposed to set in the calculation script) to a field object. If the calculation script is triggered, yo know that a field value somewhere in the form has changed. The field that triggered the script is given by event.source, and the field object that the script is attached to is given by event.target.
It could be simply:
// A field value changed, so dirty the form
bFormDirty = true;
It's not clear to me if you want the form to be dirty if the user were to check a check box and then uncheck it, leaving the form in the same initial state. If so, it would get more complicated and you'd have to compare each field value to its initial value.
For the calculation script, just set up a hidden text field whose only purpose is to include the script.
My bad....I forgot to add ".value".
Here's what happened when I attempted to use the Calculate event handler:
1) setAction was buggy - would not do text fields.
I am now going to attempt to use the Validate event handler. However, I have 100 fields that already have validate code....so those must be done by hand because of lack of "getAction()" method. How long is Adobe going to take to implement this ?
My simple approach: bFormDirty or (this.event.valueAsString != this.getField(event.target.name).valueAsString);
This worked great for checkboxes....and should have worked for textboxes as well.