It can certainly be frustrating when things don't work the way we think they should. Let's see if we can figure this out.
You say that you placed a check box on your form and copied the script I had put on the "highlight required" check box on the sample form I pointed you to but this script doesn't see to be running when you check the box? Did you put the script in the Click event? Did you set the Click event's Language property to
JavaScript?
Ideally, I believe you should be using a regular button object with a "Print" caption. In the button's Click event, in JavaScript, you would place a call to
// clear the last field to have been highlighted -- if any
ScriptObject.RemoveCurrentHighlight();
var oInvalidField = ScriptObject.HighlightRequiredFields(form1, true);
if (oInvalidField != null)
{
// found an empty required field -- ask user to fill it
app.alert("The " + oInvalidField.name + " field must be filled prior to printing this form.");
xfa.host.setFocus(oInvalidField.name);
}
else
{
// all required fields are filled -- print the form
xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 1, 0, 0, 0);
}
Of course, this implies that you've modified the ScriptObject.HihglightRequiredFields method to stop at the first-found required field which isn't filled and save it to a script object variable (such as ScriptObject.moInvalidField) and return it as an object so that you can set focus to it. It also implies that you've defined a new ScriptObject.RemoveCurrentHighlight() function which, if ScriptObject.moInvalidField isn't null, removes its highlight.
I should mention, however, that there will unfortunately always be a way for the user to print the form without going through your "print" button in order to do so ("Ctrl + P", "File | Print", print toolbar button, etc.) and while some of these functions can be disabled via some complex scripting, not all of them can be. You'll unfortunately have to expect that you may still get some printed forms which aren't completely filled. If it would be possible for you to accept data submitted via email or to a web server, there's more control over filling required fields that way.
Stefan
Adobe Systems