Expand my Community achievements bar.

Missing Fields before Printing Warning

Avatar

Level 3

I’m trying to create a form that will trigger a warning when printing if there are any missing fields. There is no data collection or document management going on.

I created two examples which have 4 text fields in a column, with a Yes and No check box side by side and then two additional check boxes below the text fields.  In both examples I created a clear button and placed it on top of the Print Form button and I placed the code on the Click function of the clear button using FormCalc.

The first example works the way it should with one small glitch. You can select both Yes and No and the form will print with out trigging the message.  Is there a way to make it that only Yes or No could be checked not both?  Also, is there a way to highlight only any missing fields??

Example 1 Code

if ((TextField1.rawValue == null) or (TextField2.rawValue == null) or (TextField3.rawValue == null) or (TextField4.rawValue == null)

or (CheckBox1.rawValue == "0") & (CheckBox2.rawValue == "0") or (CheckBox3.rawValue == "0") or (CheckBox4.rawValue == "0")) then

  1. xfa.host.messageBox("STOP! ALL
    fields must be completed in order to print this form")

else

PrintButton1.execEvent("click")

endif

The second example I thought it might be easier to name all the respected fields the same rather then creating code will all the individually named fields.   It seems like I had to name the Yes and No checkboxes different so they would work.  However, if you put text in only the second text field and check the check boxes it will print with out triggering the message.  Kind of strange because that is the only field that causes that, otherwise the second example works as it should.

Example 2 Code

if ((TextField.rawValue == null) or (CheckBox.rawValue == "0") or (CheckBox1.rawValue == "0") & (CheckBox2.rawValue == "0")) then

  1. xfa.host.messageBox("STOP! ALL
    fields must be completed in order to print this form")

  else

PrintButton1.execEvent("click")

endif

Any suggestion would be greatly appreciated.  I really don’t have much of a clue as to what I’m doing so simple is better.

1 Reply