5 Replies Latest reply on Sep 10, 2008 5:17 AM by Bernd Alheit

    Required field validation at document level

      Hi all, I hope someone can help with this. I have a form with several required fields and a Validate button which runs the following js snippet.

      var field_reqd = array_reqd;
      field_reqd[0] = "DOC.1.a";
      field_reqd[1] = "DOC.2.a";
      field_reqd[2] = "DOC.3.a";
      field_reqd[3] = "DOC.3.b";
      field_reqd[4] = "DOC.4.a";
      field_reqd[5] = "DOC.5.a";

      var alert = array_reqd;
      alert[0] = "Please enter a response to Question 1a.";
      alert[1] = "Please enter a response to Question 2a.";
      alert[2] = "Please enter a response to Question 3a.";
      alert[3] = "Please enter a response to Question 3b.";
      alert[4] = "Please enter a response to Question 4a.";
      alert[5] = "Please enter a response to Question 5a.";

      var empty = /^\s*$/;

      var fieldCount = field_reqd.length
      var fld = 0;

      for (var i=0; i < fieldCount; i++)
      {
      fld = this.getField(field_reqd[i]);
      if( empty.test(fld.value) )

      {app.alert(alert[i]); fld.setFocus(); break; }
      }

      This is fine but I can see that this will become unweildy when I move onto my next form which has 37 reqd fields. Is there a global script I can run which will validate all required fields?
      PS I am not using the 'Required' check box for these fields as I can never seem to get anything to work with it.
      thanks