Expand my Community achievements bar.

Required Fields

Avatar

Former Community Member

Hello,

When a user clicks "submit" there is a generic error message that appears. I was wondering if it is possible to have all required fields that have not been completed to appear in yellow, and how I would go abou doing this.


Thank you for your help,

Nik

3 Replies

Avatar

Level 10

Hi,

Stefan Cameron has some excellent examples: http://forms.stefcameron.com/2006/06/26/process-all-fields/

Here is another, but I can't remember where I got it (either Stefan Cameron or John Brinkman): https://acrobat.com/#d=eKOcEtArAl4N90emtEVBbQ

Hope that helps,

Niall

Avatar

Former Community Member

The one example shows the fields as yellow when you click on the field. What I want to do is have all mandatory fields which have not been completed turn yellow when the user hits submit. Is this possible?

Avatar

Level 10

Hi,

Method 1:

In the submit button the first line in the click event would call the function:

controller.validateForm(1); 

Then I added a hidden field on the form next to the submit button and used this as a flag: "statusFlag".

In the validateForm function you will see a line toward the end of the function that returns false. Above this include the following (reference would need to match your form's hierarchy/naming convention:

form1.page1.statusFlag.rawValue = "0"; 

Then there is a line where the function returns true. Again put a line above this to change the flag:

form1.page1.statusFlag.rawValue = "1"; 

Then back to the submit button. Wrap the submit script in an if statement, which looks at the statusFlag value:

if (statusFlag.rawValue == "1")

{

     // email script

}

Basic route, submit button calls function; function returns false/true; changes statusFlag value; submit looks at flag and submits if flag is one.

This is how I did it a few years ago when I came across the example. But looking at it again it could be simplified.

Method 2:

You could pass the function to a variable "formStatus", so that you do not need a hidden field AND you would not need to add the lines to the function AND the script in the click event of the submit button would look like this:

var formStatus = controller.validateForm(1);

if (formStatus == "true")

{

     // email script

}

Method 2 would be the preferred approach.

Hope that helps,

Niall