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

Form validation field help

Guest
May 31, 2017 May 31, 2017

Hi, I have a document I am preparing and one of the form fields essentially adds up 5 other fields (percentages); is there a way I can force that field to equal 100%? Perhaps an error message can appear if they are over or under so they will be alerted to go back and fix it?

If this makes the question easier to understand ~ I need employees to describe tasks that equal 100% of their daily tasks. How I have it set up now they can go over or under 100% and I would like to have an alert for them. I have never used Adobe Acrobat DC but certainly this can be done (?).

Thanks!

Tracy

TOPICS
Create PDFs
982
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
1 ACCEPTED SOLUTION
Community Expert ,
May 31, 2017 May 31, 2017

This code should do the trick (I assumed the fields are named Perc1 to Perc5... You can change it to match their actual names, of course):

if (event.value>100) app.alert("Warning! The combined value must not exceed 100%.",1);

else {

    if (this.getField("Perc1").valueAsString!="" && this.getField("Perc2").valueAsString!="" && this.getField("Perc3").valueAsString!=""

        && this.getField("Perc4").valueAsString!="" && this.getField("Perc5").valueAsString!="" && event.value!=100) {

            app.alert("Warning! The combined value must equal 100%.",1);

    }

}

View solution in original post

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
Guest
May 31, 2017 May 31, 2017

So it's allowing me to have an error message saying "the value must be greater than or equal to 100 and less than or equal to 100".

But it isn't allowing me to put a custom note in that explains it better. Is there a way I can edit the error message?

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 ,
May 31, 2017 May 31, 2017

As the custom validation script of the field you can use something like this:

if (event.value!=100) app.alert("Insert your custom message here.",1);

Note that this is probably not a good idea, because this message will appear each time the user edits one of those fields... You might want to add a condition that checks that all the fields are filled-in first before showing it, and/or if the value exceeds 100, which is always wrong.

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
Guest
May 31, 2017 May 31, 2017

How can I add a condition that checks for those things? I have tried so many things with the validation fields trying to get the warning to only show up at the end to no avail.

Thank you for getting back to me.

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 ,
May 31, 2017 May 31, 2017

This code should do the trick (I assumed the fields are named Perc1 to Perc5... You can change it to match their actual names, of course):

if (event.value>100) app.alert("Warning! The combined value must not exceed 100%.",1);

else {

    if (this.getField("Perc1").valueAsString!="" && this.getField("Perc2").valueAsString!="" && this.getField("Perc3").valueAsString!=""

        && this.getField("Perc4").valueAsString!="" && this.getField("Perc5").valueAsString!="" && event.value!=100) {

            app.alert("Warning! The combined value must equal 100%.",1);

    }

}

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
Guest
May 31, 2017 May 31, 2017

I just saw this ~ trying now! Thanks!

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
Guest
May 31, 2017 May 31, 2017
LATEST

Success! Thank you so much!

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
Guest
May 31, 2017 May 31, 2017

I'm not sure if you'll even be able to read this, but here is a ss of what I am trying to sum (not necessarily all 6 will be filled in); I feel like this should be so simple but I am stumped!

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