Skip to main content
Participating Frequently
December 18, 2023
Answered

Textbox - Problem with my script

  • December 18, 2023
  • 1 reply
  • 1731 views

Hey everyone,

 

I hope you´re all doing fine!

 

I think this is very simple to solve.

I´m having problems with my script when using a textbox in my PDF.

I created a texbox and all I want is to write a word and if the word is correct,

te user will get the message "Congratlations!", if not "Sorry, try again" and the

word in the textbox is immediately erased.

Below is the scrpt I am using:

 

-quote-

if (this.getField("Texto2").value == "been")

{
app.alert("Congratulations!")
}

if (this.getField("Texto2").value !== "been")


{
app.alert("Sorry, try again!")
this.getField("Texto2").value = "";

}

-unquote-

Can anyone help me please? I really appreciate your help in advance.

 

Andre Salles

 

This topic has been closed for replies.
Correct answer try67

Use this code as the field's custom Validation script:

 

if (event.value == "been") {
    app.alert("Congratulations!",3)
} else if (event.value) {
    app.alert("Sorry, try again!")
    event.rc = false;
}

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
December 18, 2023

Use this code as the field's custom Validation script:

 

if (event.value == "been") {
    app.alert("Congratulations!",3)
} else if (event.value) {
    app.alert("Sorry, try again!")
    event.rc = false;
}
Participating Frequently
December 18, 2023

Thank you!

 

It´s working, but now it´s showing the "Congratulations" dialog box 3 times in a row.

The positive thing is that when the word is wrong the dialog box shows up just once as it should, and the word is erased as it should.