• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Validation script issue

Engaged ,
Jan 02, 2023 Jan 02, 2023

Copy link to clipboard

Copied

I have a validaton script (provided below) that serves to populate a number of form fields based on a selection provided in a combo box drop-down list. The script in conjunction with the combo box also allows an end user to enter a new value (in the combo box) to create an additional value (essentially a name) in addition to property value pairs associated with the name that get added to a data object stored as a text file in a hidden text field on the form. Although the script performs as intended for populating form fields based on a combo box selection, upon entering a new value in the combo box subsequent to removing the text value 'Add or lookup and select a name' if the user elects to decline (respond 'No'), the script prevents adding the same typed value a 2nd time and defaults to 'Add or lookup and select a name' as opposed to asking if I want to add the new value. Any ideas, suggestons regarding what's causing this to occur and how to fix it are appreciated. Thank you ahead of time.

 

dataField =getField("dataSource");
oVendors = JSON.parse(dataField.value);
btnDel=getField("btn.del");
var oFld;
var oPassData = oVendors[event.value];
if(oPassData){
populateFormFields();
btnDel.textColor=["G",0];
btnDel.readonly=false;
btnDel.userName="Delete password record for '"+event.value+"' ?";
}
if(!oPassData)
if(event.value!="Add or lookup and select a name" && event.value!=""){
btnDel.textColor=["G",0.7];
btnDel.readonly=true;
cQuestion = "Add '"+event.value+"' to EasyPDF Password Manager?";
var Ans = app.alert({
cMsg:cQuestion,
nIcon:2,
nType:2,
cTitle: "Confirm Add Password Account by Name"
})
if(Ans==4){
//Script to append a name to oVendors object including property and value pairs
oVendors[event.value]={lastUpdate:'',website:'',userID:'',password:'',primaryCC:'',secondaryCC:'',primaryBank:'',secondaryBank:'',sq1:'',sa1:'',sq2:'',sa2:'',notes1:'',notes2:''};
dataField.value = JSON.stringify(oVendors);
updateCBNames();//function to append name of object recently added to oVendors to the combo box drop-down list
var bMatch=false;
for(i=0;i<event.target.numItems;i++){//restore combo box drop-down value to name recently added to begin adding asssociated property values
cName=event.target.getItemAt(i);
if(cName==event.value){
bMatch=true;
event.target.currentValueIndices=i;
cFld=getField("inf.lastUpdate");
cFld.setFocus();
}
if(bMatch)
break
}
}
else
//if(Ans==3)
event.target.currentValueIndices=0;
}
else
if(event.value=="Add or lookup and select a name"){
this.resetForm("inf");
btnDel.textColor=["G",0.7];
btnDel.readonly=true;
}

TOPICS
How to , JavaScript , PDF forms

Views

620

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
Community Expert ,
Jan 03, 2023 Jan 03, 2023

Copy link to clipboard

Copied

First, it is very difficult to follow your code because it is poorly formated. Please use the provided code box and use indents. 

 

Next, this code is thrashing the combobox.  Changing anything about the combobox items will cause the validation script to be called recursively.  Code needs to be added to block any reentrant calls.  I would suggest using console.println statements to track the sequence so you know exactly what is happening. 

 

 

 

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

Votes

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
Enthusiast ,
Jan 03, 2023 Jan 03, 2023

Copy link to clipboard

Copied

Please do not try to help this user anymore, he was really rude to other members on this forum.

https://community.adobe.com/t5/acrobat-discussions/how-to-modify-an-existing-validation-script-depen... 

Votes

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
Engaged ,
Jan 03, 2023 Jan 03, 2023

Copy link to clipboard

Copied

Not true. I suggest you review my previous posts. I was not the one who was initially rude as I was dissed by someone else in response to one of my earlier posts. I don't know who you are but using alias names to post such a remark telling others not to respond to my posts is uncalled for and rude in itelf! Can you please dispense with the vitriol whoever you are?  

Votes

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
Engaged ,
Jan 03, 2023 Jan 03, 2023

Copy link to clipboard

Copied

Thanks Thom. I will definitely try your suggestion using the console println statements to see if this can help me correct the issue I am having with the script. Regarding the code box, I must be missing something as I don't readily see it. I must admit that I simply copied and pasted the code and for whatever reason all my indents vanished. What can I do next time to prevent this from happening?   

Votes

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
Community Expert ,
Jan 03, 2023 Jan 03, 2023

Copy link to clipboard

Copied

The code box is one of the forum tools. It's the angle brackets </>, right next to the spell checker

 

 

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

Votes

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
Engaged ,
Jan 03, 2023 Jan 03, 2023

Copy link to clipboard

Copied

Thank you for the clarification. I was unaware of this tool and will be sure to check it out when posting future scripts. I must be blind as I have been scrolling the page up/down looking for the spell checker and brackets you referred to but I do not see it anywhere. 

Votes

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
Community Expert ,
Jan 03, 2023 Jan 03, 2023

Copy link to clipboard

Copied

This is what the forum message entry looks like to me. 

 

AcroForum_Tools.jpg

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

Votes

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
Engaged ,
Jan 03, 2023 Jan 03, 2023

Copy link to clipboard

Copied

Got it! I must admit that I wasn't aware that the tools are only displayed in the dialog box when entering a reply. In reality, the symbols are so small I may need glasses since I never really noticed them until now. I will definitely make sure to utilize the tools provided when I can in the future.

Votes

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
Engaged ,
Jan 04, 2023 Jan 04, 2023

Copy link to clipboard

Copied

LATEST

Thom,

I just wanted to let you know that I was able to resolve the script issue I was having in which event the solution was actually staring me right in the face all along in that it was due to a conditional 'if' statement that was performing corectly given the way it was written but not what I intended. What made it difficult in my particular instance was my anticipating to find the cause and correct the problem by stepping through the code using the console.println. At first, I thought I must be doing something wrong since I wasn't getting any results whatsoever. However, it wasn't until I stumbled across one of your past articles online regarding using multiple conditional if statements that drove me to take a hard look at my script related to an else part of my conditional statement and voila, problem solved. I just wanted to add that your article was the catalyst that helped me resolve this issue once and for all for which I am thankful.

Votes

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