Quantcast
Channel: Adobe Community : All Content - LiveCycle Designer
Viewing all articles
Browse latest Browse all 5571

How to validate required fields before executing menu item ("Save As") using cutom Javascript?

$
0
0

Hi,

 

Sorry, I am new to PDF Development. I tried creating PDF using Acrobat XI Pro. During creation, I have encountered issues in running custom JavaScript. The requirement is to validate all the required fields before saving the PDF. I tried using the following scripts to validate the said required fields. But, it's not working.

 

Option 1: If the field is null, a message box will appear.

if(this.getfield("textbox") = null){

app.alert("required");

}

else {app.execMenuItem("SaveAs");}

 

Option 2: If the field is required, a message box will appear.

var f = this.getField("textbox");
f.required = true;

if(f = true)
{
app.alert('required');
}
else
{
app.execMenuItem("SaveAs");
}

 

The scripts mentioned above are not working. I wanted to validate the required fields before saving the PDF.

 

In addition, I tried validating each field using the following script:

f = getField(event.target.name)

if (f.value.length == 0)

    {

    f.setFocus()

    //Optional Message - Comment out the next line to remove

    app.alert("This field is required. Please enter a value.")

    }

 

When I open the PDF, the script is working. However, when the message box pops out, the "OK" button is not working as expected. The message box is not closing. I tried opening the form in a site in different Java versions (like 7-11 and 7-67). It's working in version 7-67. I tried upgrading the Java version from 7-11 to 7-67. Still, it doesn't work.

 

I would appreciate your feedback on this matter.

 

 

 


Viewing all articles
Browse latest Browse all 5571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>