Expand my Community achievements bar.

SOLVED

Invalid enumerated value: validationState

Avatar

Level 3

Hi there,

I need help, desperately.

I made a form using Desinger ES2, and set its target version to 9.1 or later.  When it is rendered in the browser/standalone with Reader Version 9.0, it would pop out "Invalid enumerated value: validationState", twice...

I do a version check in the form's formReady event, it hides the entire form if version is not >= 9.1, and also pops up a message box telling the user that they do not have the latest Reader and should update or the form would not display/function properly.  BUT our client is still not happy with the sollution and complains about seeing this popup when they load it in 9.0.

I need help getting rid of this popup in version 9.0 please.

Regards,

Nelson Wei

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Nelson,

First off I would recommend that you don't delete script from inside the XML Source. Yes, it can be done, but could easily break your form, potentially beyond repair.

If you select the root node (form1) and go to the script editor. Then from the Show dropdown select ValidationState, you can quickly scroll down and find the object with script in that event. I suspect that it is in the form1 node anyway.

My experience is that when you deselect the colour mandatory fields in the form properties, that LC Designer deletes the auto generated code. If you amended the code beforehand, it may fail to detect it and not remove it.

In relation to v9 and below there are a number of ways to handle validation - so it is do-able, but not as straightforward as v9.1. I would recommend John Brinkman's blog, as he has some samples of heavily (but elegantly) coded 'show errors' forms. http://blogs.adobe.com/formfeed/. Search for 'validation'.

The standard Submit buttons will pick up if a required field is null and automatically highlight it in red. However for fields that are required and have a value OR fields that are not required and have an invalid value, LC/Acrobat will not highlight these in red.

Out-of-the-box validation will give you an error message if the value is invalid. This happens on exiting the field and on submit - no colouring. You can add a line of code to other buttons (like Print) or in the prePrint event, to validate before they execute their own script:

form1.execValidate(); 

You would wrap it as a test in an if statement, so that the form would only print if the data was valid.

So:

  • lowest solution, individual validation on specific objects, means lots of alerts, which the user can ignore and no colour highlighting.
  • Follow John Brinkman's solutions for custom functions to handle validation.
  • Users upgrade to v9.1.

I hope that helps,

Niall

View solution in original post

4 Replies

Avatar

Level 10

Hi Nelson,

This came up in a thread yesterday.

I suspect that in LC Designer ES2 you are using the new Form Validation Handling feature (File > Form Properties > Form Validation).

If so this will have inserted some script objects with functions to handle the validation. The colour fields function is called from the new event validationState.

This is where your problem lies. This event was added in XFA Specification 3.0 (Acrobat 9.1). So if the user loads the form in v9 or lower, the valdationState event just isn't there to handle the script - hence the popup message.

If users are going to have v9 or below, I would deselect all of the form validation handling in the properties window.

Good luck,

Niall

Avatar

Level 3

Hi Niall,


Thanks for your help.  I only had "Set Focus" checked, but I have turned it off after your suggestion, I still get the same popup.  So I am guessing it is been called during initialization or somewhere I have no control with.

I actually took out the following code in the xml, and that does get rid of the popup, but down side is that I lose the coloring feature when fields are invalid in Reader 9.1 or later (which is the required version).

<event activity="validationState" listen="refAndDescendents" name="event__validationState">
         <script contentType="application/x-javascript">ColorFieldsValidation.DoColorFields(xfa.event.target);
</script>
      </event>

How was coloring done before 9.1?  Should I implement our own coloring functions instead?    Is there another way to handle this?

Thanks again,

Nelson

Avatar

Correct answer by
Level 10

Hi Nelson,

First off I would recommend that you don't delete script from inside the XML Source. Yes, it can be done, but could easily break your form, potentially beyond repair.

If you select the root node (form1) and go to the script editor. Then from the Show dropdown select ValidationState, you can quickly scroll down and find the object with script in that event. I suspect that it is in the form1 node anyway.

My experience is that when you deselect the colour mandatory fields in the form properties, that LC Designer deletes the auto generated code. If you amended the code beforehand, it may fail to detect it and not remove it.

In relation to v9 and below there are a number of ways to handle validation - so it is do-able, but not as straightforward as v9.1. I would recommend John Brinkman's blog, as he has some samples of heavily (but elegantly) coded 'show errors' forms. http://blogs.adobe.com/formfeed/. Search for 'validation'.

The standard Submit buttons will pick up if a required field is null and automatically highlight it in red. However for fields that are required and have a value OR fields that are not required and have an invalid value, LC/Acrobat will not highlight these in red.

Out-of-the-box validation will give you an error message if the value is invalid. This happens on exiting the field and on submit - no colouring. You can add a line of code to other buttons (like Print) or in the prePrint event, to validate before they execute their own script:

form1.execValidate(); 

You would wrap it as a test in an if statement, so that the form would only print if the data was valid.

So:

  • lowest solution, individual validation on specific objects, means lots of alerts, which the user can ignore and no colour highlighting.
  • Follow John Brinkman's solutions for custom functions to handle validation.
  • Users upgrade to v9.1.

I hope that helps,

Niall

Avatar

Level 3

Hi Niall,

Cool, I will look into ur suggestions, that was very very helpful, I think I have an idea what to do now, thanks a lot for your help, again. 

Regards,

Nelson Wei