Copy link to clipboard
Copied
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
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);
}
}
}
Copy link to clipboard
Copied
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)?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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);
}
}
}
Copy link to clipboard
Copied
Mr. Gilad
Thank you Very much
you are a legend really
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now