Text box needs clicking twice to enter text when added javascript

New Here ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

I have created a pdf form in Adobe Acrobat DC version 2021.001.20145 (mac). The layout was created in Adobe Indesign (mac).

The text boxes work fine when there is no javascript applied to them. The client wants to have a pop up to tell the user to fill in the field if they skip the box:

Action: On blur

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.") }

 

If the user fills in each text field and does not skip any boxes, all is fine.

When the user skips a box, then goes back and fills it in, then goes to the next box, the user needs to click on that text box twice to fill it in. If they click on the box once, they can fill it in but the text is invisible while it gets typed. Has anyone gotten this bug before and if yes how can it be fixed?

TOPICS
Create PDFs, JavaScript, PDF forms

Views

217

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

++ EDITED REPLY,

 

You may need to share the PDF to get better assistance. Is hard to tell what could be going on with that PDF.

 

Without looking at the code that you're currently using, or examining the field objects that are dependent of other calculating events is hard to  tell, specially if you're running custom calculated scripts in other fields.

 

Also, why are you using an On-Blur mouse event in a field as a field property? Shouldn't this event type used with widgets?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

Hi ls_rbls,

How do I share the pdf?

The code came from Googling so if there is a better mouse event to use then that would be great.

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

Here is the test form

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

On the first page, all of the text fields have the script, and to show the difference, all of the text fields on the second page are clear of any scripts and work normally.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 11, 2021 Apr 11, 2021

Copy link to clipboard

Copied

Can anyone help? It's gotten quiet. The file is there to have a look.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 12, 2021 Apr 12, 2021

Copy link to clipboard

Copied

LATEST

First, "event.target" is the field object, so there is no reason to call get field. Change your code to this.

if(event.target.value.length == 0) 
{ 
   event.target.setFocus();
   app.alert("This field is required."); 
}

 

You might also consider using a different field validation method.  This code sets up some potential conflicts, i.e. it sets focus on a blur event, so the action is potentially conflicting with the states of both the current fields and the next field.  

 

This is rather odd behavior. It's possible that this conflict is responsible for the issue.

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines