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

app.alert and if

Community Beginner ,
Feb 12, 2018 Feb 12, 2018

I have a form and one of the text fields is called BP

I am tryning to figger out a way to have an alert =, if the BP (Blood Pressure) is >=160/100 an alert will pop up "High Blood Pressure!"

and if the blood pressure is <= 90/60 an alert will pop up "Low blood pressure!"

please any hlep

TOPICS
Acrobat SDK and JavaScript , Windows
1.2K
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

correct answers 1 Correct answer

Community Expert , Feb 12, 2018 Feb 12, 2018

Use this code as the field's custom validation script:

if (event.value) {

    var parts = event.value.split("/");

    if (parts.length==2) {

        var v1 = Number(parts[0]);

        var v2 = Number(parts[1]);

        if (!isNaN(v1) && !isNaN(v2)) {

            if (v1>=160 && v2>=100) app.alert("High Blood Pressure!",1);

            if (v1<=90 && v2<=60) app.alert("Low Blood Pressure!",1);

        }

    }

}

Translate
LEGEND ,
Feb 12, 2018 Feb 12, 2018

That might be kind of difficult if you're using just a single field for the systolic and diastolic values. If you use separate fields, it becomes easier, and easier to validate entries, since they will be numbers instead of a string that you have to parse to extract the two values. Also, would both values have to exceed their respective upper limits (e.g., 161/101) to be considered too high, or just one (e.g., 161/99)?

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 Beginner ,
Feb 12, 2018 Feb 12, 2018

greetings Mr. George

thanks for your reply

unfortunately the feild should be one only not more, for the value if both exceeded the limit is acceptable

thank you again

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 ,
Feb 12, 2018 Feb 12, 2018

Use this code as the field's custom validation script:

if (event.value) {

    var parts = event.value.split("/");

    if (parts.length==2) {

        var v1 = Number(parts[0]);

        var v2 = Number(parts[1]);

        if (!isNaN(v1) && !isNaN(v2)) {

            if (v1>=160 && v2>=100) app.alert("High Blood Pressure!",1);

            if (v1<=90 && v2<=60) app.alert("Low Blood Pressure!",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
Community Beginner ,
Feb 12, 2018 Feb 12, 2018

Mr. Gilad

Thank you Very much

you are a legend really

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
LEGEND ,
Feb 12, 2018 Feb 12, 2018
LATEST

If this is going to be used for anything important, consider adding additional validations to catch erroneous inputs. For example, check to make sure the values are within a reasonable range (e.g., 50-300 / 20-200), that systolic is greater than diastolic, etc.

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