These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Text box validate

analb78
Registered: Jul 27 2008
Posts: 6

Hello all,
I have a problem with textbox validate script. i want to check validation of textbox 3 time and after 3 wrong attempt automatically right answer will display in a message box.
Ex:
var n=getField("item2").value;
if(n !="lightning")
{
app.alert("Try again...",3)
}
else
{
app.alert("Correct... ",3);
}

this code working properly, but i want to check it 3 times and then answer(anything message) will appear.

thanks,

My Product Information:
Acrobat Pro 9.1.1, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
You can keep a global counter that increments with each attemp, and when it equals 3 display the message you want.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

analb78
Registered: Jul 27 2008
Posts: 6
Thanx try67,
but where to declear global counter?i wrote the script against a button, can you give me an example?
thanx in advance
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Well, you can place it within the button itself. I don't have the exact code right now, but basically you check first if the type of your global variable is undefined. If it is, you create it, if not you increment it and then check its value.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com