Copy link to clipboard
Copied
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!!
Copy link to clipboard
Copied
Use the validation event, instead.
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
Use this code:
if (event.value) {
if (event.value == "on") {
app.alert ("Congratulations!", 3,0);
} else app.alert("Incorrect answer. Try again", 0,0);
}
Copy link to clipboard
Copied
Thanks! It´s working now.
BUT, I still have another problem. Sorry!
I decided to include one last line, before the last closing brace, to clear the text field (as follows), in case the answer is wrong.
event.value = "";
But it´s not working properly, because now it is clearing even the right answers.
Is there a better position to include that line?
Thanks you very much in advance!!
Copy link to clipboard
Copied
HI,
Just add it so the code looks like
if (event.value) {
if (event.value == "on") {
app.alert ("Congratulations!", 3,0);
} else {
app.alert("Incorrect answer. Try again", 0,0);
event.rc = "";
}
}
Copy link to clipboard
Copied
No, it should be:
event.rc = false;
Copy link to clipboard
Copied
Everything is working fine now.
Thanks you very much!!
Copy link to clipboard
Copied
Thank you very much, sir!