Skip to main content
Participating Frequently
February 12, 2018
Answered

app.alert and if

  • February 12, 2018
  • 2 replies
  • 1255 views

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

This topic has been closed for replies.
Correct answer try67

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);

        }

    }

}

2 replies

try67
try67Correct answer
Adobe Expert
February 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);

        }

    }

}

Participating Frequently
February 12, 2018

Mr. Gilad

Thank you Very much

you are a legend really

Inspiring
February 12, 2018

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.

Inspiring
February 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)?

Participating Frequently
February 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