Expand my Community achievements bar.

Required field loop

Avatar

Level 2

I have two fields: field1 and field2. Both are set as “User Entered - Required”. I am trying to enforce that they cannot be empty. I made the following routine, but when I leave field1 empty and click on the field2 (which is also empty) I get stuck in an infinite loop of the same error message from both fields.

Using FormCalc on the Exit event:

if ($.isNull) then

    xfa.host.messageBox("Field cannot be blank!")

    $host.setFocus  ($.name)

endif

2 Replies

Avatar

Level 10

You have to have one way or other..

Change both the field's option to "User Entered - Optional". That can remove the infinite loop.

If you want to check the required value with the script in the Exit event, then you also need to check for both the field's input before user submit the form.. So if you are using a Submit button, preSubmit event you have to check for the field value.

Thanks

Srini

Avatar

Level 2

Changing the type to "User Entered - Optional" doesn't make a difference as the message comes from the code itself.

I am not using a submit button and don't really want to rely on the user actually hitting the button, which most won't.

At the moment I just disbaled the statement $host.setFocus ($.name), but since Acrobat doesn't really enforce that it be actually required it would just display the messagebox.