I'm using LiveCycle Designer 8.
I have an Image field in a form with a validation java script that checks the size of the image that the user is adding. If the image is over 1MB, I issue a warning, but leave the image. There is no problem there.
However, after the file is saved and upon opening the PDF, the LCD seems to run through all the validate scripts and therefore, issues the size warning.
Any ideas how I can avoid the warning when the form is opened?
All suggestions are appreciated....
Solved! Go to Solution.
Views
Replies
Total Likes
Hi David,
While you can use a textfield to act as a flag, I find it easier to use a numeric field with "1" for on and "0" for off.
You could try putting the script for the image field in the mouseUp event, but I don't think it will work because at mouseUp Acrobat opens the dialogue window to select the image.
I think Paul's solution is based on:
You would potentially need a flag for each image field.
I stand to be corrected ;-)
N.
Views
Replies
Total Likes
What event did you run your code on to give the warning in the 1st place?
Paul
Views
Replies
Total Likes
Thank you for your question.
It's in the validation event
Views
Replies
Total Likes
The validate event will fire each time you open the form. Move the code to another event that will only fire when the user does something (i.e. the exit event).
Paul
Thank you for the feedback.
I did move the code to the exit event, but from an end-user perspective, I found this a bit confusion. For example, I have the imagefield (photo) and a text field (title),
If the user adds an image that is too big and I put the code in the exit event (nothing happens), then when they click on the title field, they get the imagefield message.
If there a way with java script to put code in the function that might say something like, "if the user is on this imagefield, then check for size, otherwise, don't check?
Views
Replies
Total Likes
You could set a flag in another field when the user sets the image then check the status of the flag to see if you should display the message of not.
Paul
Views
Replies
Total Likes
Getting close....
Because I'm a newbie, I'm not sure how to change the value of a different field and I will need this for your suggestion to work.
To make it simply, assume that I have two fields MyFirst and MySecond.
Assume that I'm on the first field (MyFirst). What would I put in the calculate event to change MySecond to, say "abc"
Thank you for your help.
Views
Replies
Total Likes
It is as simple as this:
MySecond.rawValue = "Vlaue that you want to set"
Paul
Thank you the feedback.
My problem here was that when I created my objects, I used dashes in the names, as in "My-First-TextField" and this caused all kinds of problems -- problems that you don't want to wrestle with when you are learning something new!
Since renaming all my objects, most of these problems have disappeared.
Thanks again.
Views
Replies
Total Likes
Thanks Paul,
This is the way I need to go here. However, this is proving more difficult that it first looks.
I created a variable called JustOpened and set the initial value to "yes"
In my validate routine, I set JustOpened to "no" and then call my function.
This does not work because, as you indicate, the validate function is called when the form opens.
I like the idea of having the JustOpened variable and I think that having the default set to "yes" could work. However, where could I set JustOpened to "no" so that my validation works as intended?
Views
Replies
Total Likes
Hi David,
While you can use a textfield to act as a flag, I find it easier to use a numeric field with "1" for on and "0" for off.
You could try putting the script for the image field in the mouseUp event, but I don't think it will work because at mouseUp Acrobat opens the dialogue window to select the image.
I think Paul's solution is based on:
You would potentially need a flag for each image field.
I stand to be corrected ;-)
N.
Views
Replies
Total Likes
Resolved...finally!
To resolve this I setup a variable (File, Form-Properties) called JustOpened. I set the default value to "yes"
I then put JustOpened.value = "no" in a form:ready event (you can use any object for this).
I then put JustOpened.value = "yes" in the DocClose event (you can use any object for this too).
In my validate function, I only execute the validate code if JutOpened = "no."
Works like a charm.
What I learned through this is that each object has associated with it, a list of (I think they are methods) methods that are executed when the form is opened. They include Initiate, Calculate, Validate, FormReady, and LayoutReady. In addition, everytime a user edits a form field, the LayoutReady method is executed. Understanding this makes a HUGE difference when coding a form.
Thanks for the help....
Views
Replies
Total Likes