Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

How to compare value fo text field with string on click of button.

Avatar

Former Community Member
Hi All,



I want to compare value of text field with a string on click of button and print a alert message in pop up.Also if possible i want to forcefully close the pdf on click of "ok" button of pop up.



Using javascript client side.



Please help me out.

Vishal Doshi.
5 Replies

Avatar

Former Community Member
The script would look like:



if ("foo" != TextField.rawValue) {

xfa.host.messageBox("You must enter foo!");

event.target.closeDoc();

}



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
See the code in the click event of the button of the attached sample.



Regards

Denver



Adobe Enterprise Developer Support

Avatar

Former Community Member
Hi Denver Green,

Thanks a lot .

It has helped me solve my problem of reading value and printing message box.But my pdf gets opened on click of hyperlink which then opens in internet explorer.Therefore on click of "OK" of the message box it gives the following (Adobe Acrobat) message:

"This action cannot be performed from within an external window."

and the pdf does not get closed.



So app.execMenuItem("Close"); i guess it doesnot work .



Can you help me out.



Regards,

Vishal Doshi

Avatar

Former Community Member
I'm sure app.execMenuItem("Close") works fine when running the form in Reader or Acrobat outside of the browser but within a browser, I think you would run into problems such as the one you're describing.



If your form will always be viewed within a browser, how about simply navigating to some "exit" URL? As a matter of fact, you could create a little HTML file that has a "window.close" call in its initialization script and point the browser to that URL when the user clicks on the button like this:



app.launchURL("close.html");


This might have the effect you're looking for within a browser window.



Stefan

Adobe Systems

Avatar

Former Community Member
Thanks..

Instead of closing the pdf i am calling reset() thats serving my purpose.Your solution helped me lot.



Thanks and Regards,

Vishal Doshi.