2 Replies Latest reply on Jul 23, 2015 8:12 AM by craigd23207817

    Create Acrobat Form Field with JavaScript and Restrict to Numeric Values Only

    craigd23207817

      Hi,

       

      I am using a JavaScript loop to create a number of similar form fields. I am trying to restrict the data entered in these fields to numbers only. I am able to validate numbers that are entered, but the fields still accept text, which I don't want. How can I ensure text is not accepted?

       

      Script:

       

      var x1 = 53;
      var y1 = 358;
      var x2 = 123;
      var y2 = 340;

       

      for (var i = 1; i < 18; i++) {
          var name = "myField" + i;
          var type = "text";
          var page = 1;
          var location = [x1,y1,x2,y2];
          var myField = this.addField(name, type, page, location);
          myField.textSize = 10;
          myField.setAction("Validate","AFRange_Validate (true,0,true,100)");
          myField;
      y1 -= 18;
      y2 -= 18;
      };