Skip to main content
Inspiring
April 22, 2021
Question

How can I create a textfield that checks the input value without the need of a button?

  • April 22, 2021
  • 1 reply
  • 1029 views

Hi everyone,

 

I´m trying to create a textfield to check the input (word) and pops up a message in case the answer is right.

The problem is: In ase the answer is wrong and the user mouseclick the textfield again, the message pops up again, before the field is cleared.

 

I´m using the following script in the Custom Keystroke Format section:


if(event.value == "on"){

app.alert ("Congratulations!", 3,0);

}

else if (event.value == "in"){

app.alert("Incorrect answer. Try again", 0,0);

}

else if (event.value == "at"){

app.alert("Incorrect answer. Try again", 0,0);

}

 

 

Thanks a lot in advance for your help!!

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
April 22, 2021

Use the validation event, instead.

try67
Community Expert
Community Expert
April 22, 2021

PS. You might want to consider using a generic "Incorrect answer" alert if the text is anything but "on", instead of specifying all possible wrong answers...

Inspiring
April 22, 2021

 

Thanks you very much! It worked fine.

Only now, I´m having problems clearing the fields programatically via a menu button.

An error message pops up for every textfield.

I´m using the following script:

 

var fields = new Array();

fields[0] = "Text25";
fields[1] = "Text26";
fields[2] = "Text27";
fields[3] = "Text28";
fields[4] = "Text29";
fields[5] = "Text30";
fields[6] = "Text31";
fields[7] = "Text32";
fields[8] = "Text33";
fields[9] = "Text34";

this.resetForm(fields);