function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ClaiborneClaiborne 

Detect a Required Field on an Inactive Tab

I have a VisualForce page with multiple tabs.

 

Each tab has <apex:inputField> tags were required=true. The fields are not required at the object level, only on the VisualForce page.

 

When the page invokes any action, the action will not execute unless all required fields on all tabs, even the ones that are inactive and not visible, are completed.

 

This is OK. I want to user to complete all information.

 

My problem is that I do not have a way to let the user know that the missing information in on an inactive tab. 

 

Does anyone know how to determine which tabs have uncompleted required fields so that I can provide some indication to the user?

 

Ideally, I would like a way to change the tab indicator to show that data is complete on the tab or not.

 

I am guessing I need some sort of Javascript to cycle through the elements in each tab. 

 

Thanks.

 

 

aj2taylo2aj2taylo2

The only way I can think of, which is a bit messy, is do all the validation in the controller/extension, and remove required=true from the inputFields (and add styling to indicate to the end-user that it is required).  This way, you can customize the error message (e.g. please click on Tab X and enter a value for field Y).

 

Alternatively, your Javascript/jQuery idea may work, to change visibility of the tabs as the user proceeds through the form.