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

Display an error message if two fields have the same value

New Here ,
Jul 10, 2023 Jul 10, 2023

Hello everyone, 

I have a pdf form with several boxes to fill in: first name, surname, email. This information is to be filled in for two people in each section of a company. I've set up drop down lists for each contact in case the person to contact is the same person as a contact already filled in. For example, if the main contact of the TML section is the same person as the main contact of the RM contact, the person filling in the form will just have to select RM Main contact in the dropdown list, and the first name, surname and email fields will be automatically filled in with the same values as for the contact of the RM section. But as I said, I have two contacts per section and I want the second to have different information from the first. Already in the dropdown list of the second contact, there's no option to specify that it's the same as the main contact. However, there is a case where the main contact in one section is the same as a contact in another section, and the person can select this same contact for the secondary contact, which means that the main and secondary contacts will be the same. I'd like it to be the case that when the person selects the same contact in the dropdown list or when he inserts the same email as the main contact, a message appears saying that the main and secondary contact of the same section can't be the same. Do you have any ideas for I could achieve that ? (sorry for ny english and I'm also a beginner with adobe acrobat).

Thank you

My script for one field linked to a dropdown list looks like that : 
if(event.value=="...")this.getField("TLM_AC_Fname").value="";
if(event.value=="SPM Main contact")this.getField("TLM_AC_Fname").value=this.getField("SPM_MC_Fname").value;
if(event.value=="SPM Alternate contact")this.getField("TLM_AC_Fname").value=this.getField("SPM_AC_Fname").value;
if(event.value=="TRGT Main contact")this.getField("TLM_AC_Fname").value=this.getField("TRGT_MC_Fname").value;
if(event.value=="TRGT Alternate contact")this.getField("TLM_AC_Fname").value=this.getField("TRGT_AC_Fname").value;
if(event.value=="RM Main contact")this.getField("TLM_AC_Fname").value=this.getField("RM_MC_Fname").value;
if(event.value=="RM Alternate contact")this.getField("TLM_AC_Fname").value=this.getField("RM_AC_Fname").value;
if(event.value=="CM Main contact")this.getField("TLM_AC_Fname").value=this.getField("CM_MC_Fname").value;
if(event.value=="CM Alternate contact")this.getField("TLM_AC_Fname").value=this.getField("CM_AC_Fname").value;

TOPICS
How to , JavaScript , PDF , PDF forms
229
Translate
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 ,
Jul 10, 2023 Jul 10, 2023
LATEST

I don't understand how the script you posted is related, but you can do it like this (as the custom validation script of the second field):

 

if (event.value && event.value==this.getField("FirstField").valueAsString) {

app.alert("The value can't be the same as that of FirstField.");

event.rc = false;

}

 

Note that this will still allow the user to enter a different value, and then go back to the first field and change it so the two are the same, unless you add a similar code there, too.

Translate
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