2 Replies Latest reply on Jun 19, 2014 9:00 AM by simonhemmings

    Help with clearing form after print takes place


      Hi everyone, im new to javascript, and im after a little assistance if possible.


      Belwo is a script im using, which works fine, however I want to slightly tweek it, ive grabbed this info from other people and put it together, so it works.


      My question is, can I form clear only if printing takes place?


      I can put a form rest in, the frustration is, that if they don't fill in all of the fields and they press submit, it simply resets all of the fields and forces them to fill it all in again.


      I would prefer if it does what it does so far, but only clears the form after print takes place.


      I hope this makes sense.


      Below is the script.




      // On Blur script

      if (!event.target.valueAsString) {

          app.alert("When prompted, print the form as  ISSUE FORM (todays date) Click ok to continue", 3);


      var emptyFields = [];

      for (var i=0; i<this.numFields; i++) {

           var f= this.getField(this.getNthFieldName(i));

           if (f.type!="button" && f.required ) {

                if ((f.type=="text" && f.valueAsString=="") || (f.type=="checkbox" && f.value=="Off")) {
      } else

      if (emptyFields.length>0) {

           app.alert("Error! All fields below must be complete:\n" + emptyFields.join("\n"));


      else {





      thank you kindly in advance

        • 1. Re: Help with clearing form after print takes place
          George_Johnson MVP & Adobe Community Professional

          You should be able to add a resetForm statement after the print statement:


          else {







          I didn't test it, so post again if it doesn't work.

          • 2. Re: Help with clearing form after print takes place
            simonhemmings Level 1



            I found a way round it, the issue I was having with resetting after the print, is that if a mistake was made and they press submit, it was resetting whole form again, which becomes a pain for users,


            What I've just sussed and im so happy with it, was that by adding a fields clear command at start up, meant that they could make a mistake, the form would not reset, but if they saved over the form name, it would simply give a clear form next time on start up!




            Let me know if you need to see this code, although I'm sure it would be very basic stuff for yourself.


            I really appreciate your help though George, and your time taken to respond back to me.


            Forums are a great help to new starters, but half the time it's knowing how to write in what you're searching for,


            I've only been working with javascript for 48hrs now, so it's a great relief to have finalised this code!


            Thx again George,


            My regards,



            Simon Hemmings






            Telephone    01708 755 733

            Mobile          07983 964 764

            Fax              0207 138 2561

            Email           simon.hemmings@margalgroup.com

            Web            www.margalgroup.com