6 Replies Latest reply on Feb 6, 2013 4:27 AM by try67

    Acrobat v9 JavaScript Alert Box - any way to add space or line break after each array item?

    Compliance Issues Level 1

      I have a Document level Javascript used to identify blank required fields and is triggered on document actions, Print and Save. The script identifies the blank required fields, counts them, and outputs to an Alert box indicating the number of required fields blank and lists the fields by tooltip name. The script identifies the required fields by an asterisk at the end of each tool tip.

       

      My question is there any way to add a space or a line break after the comma for each listed item?

      Here is an image of the output where the listed items are all run together.

      Alert box array items need space or line break.jpg

      Here is the code:

      function validateFields()

      {

      //a counter for the number of empty fields

      var flg = 0

      // count all the form fields

      var n = this.numFields

      //create an array to contain the names of required fields

      //if they are determined to be empty

      var fArr = new Array();

      //loop through all fields and check for those that are required

      // all fields that have a '*' in their tool tip are required

      for(var i = 0;i<n;i++){

      var fn = this.getNthFieldName(i);

      var f = this.getField(fn);

      //tool tip is the fields\'s 'userName' property;

      var tt = f.userName

      //test for the '*';

      if(tt.indexOf('*')!=-1 && f.value == f.defaultValue){

      //increment the counter of empty fields;

      flg++;

      //add the fields userName (tool tip) to the list of empty field names;

      fArr[fArr.length] = tt;

      }

      }

      //now display a message if there are empty fields

      if(flg>0){

      app.alert('There are '+flg+' fields that require a value\n\n'+ fArr,3)

      }

      else{

      this.print();

      }

      }