Copy link to clipboard
Copied
I'm trying to program a button to check required fields in a form. The goal is to walk the user through the fields that need attention. Right now it jumps to the field and highlights it. I want it to wait for the user to enter data before removing the highlight and jumping to the next field. Can someone show me a way to implement this?
for (var i = 0; i < this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f.type != "button" && f.required && f.value == "") {
f.setFocus();
f.fillColor = color.yellow;
// Wait for user to enter something in f
f.fillColor = color.transparent;
}
}
Copy link to clipboard
Copied
A script can't loop until the user does something, because the user can't do anything until your script finishes. And a script can't wait for events. What you have to do is divide your processing up into pieces that are triggered by different events, with global variables to control the current state. Or, less ambitious, expect the user to check again.
Copy link to clipboard
Copied
It can, actually, using a time-out, but that's not a good way of doing things. It's much easier to use the other field's OnBlur event directly for it.