These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

image field content size

rhet
Registered: Aug 4 2009
Posts: 3

How would I check for an image's size and reject images that are above a certain size, giving the user a pop up message telling them to choose a smaller file if they try to insert one thats too big?

I found this script that i've been trying to make work:

if(image1.value.image.value.length > 1400000)
{
this.validationMessage = "Image larger than 1MB . Please select a smaller image.";
0;
}

but it keeps giving me a 'validate failed' message.

Can anyone help me with this? I have very little javascript knowledge and just need to do this one thing that is driving me nutty.

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
I've tried around a bit, and finally I got it work with this script.

if(ImageField1.resolveNode("value.#image").value.length > 1048576){ImageField1.validationMessage = "Image larger than 1MB . Please select a smaller image."}

Here is an example file
https://share.acrobat.com/adc/document.do?docid=69eaf83f-6435-4e91-8a9f-7ce43a4b1d9b

But, this will not stop the import of the image it only will alert the user through the message.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs