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

Is there a way to wait for blur on field before continuing loop?

New Here ,
Feb 07, 2019 Feb 07, 2019

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;

    }

}

TOPICS
Acrobat SDK and JavaScript

Views

250

Translate

Translate

Report

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 07, 2019 Feb 07, 2019

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.

Votes

Translate

Translate

Report

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 07, 2019 Feb 07, 2019

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

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