Client side validation do not stop calling Action if input is hidden (display:none)

Hi people,

This is almost more like a curiosity, but...

P10 page with a form and many inputs. One of it, mandatory, is hidden (Display property set to a condition that will resolve to False).
Button set to Client & Server, and Ajax Submit.

If I fill the other inputs, when I click the button the automatic validation (client side) is executed. The hidden input Valid property is set to False, as it is there, just not visible. Because of this, the Form Valid property is also set to False. 

But despite the validation being set to CLIENT & Server, and the form is invalid, the action is executed.
On starting, the Form is invalid.

The workaround is simple (and good practice anyway): Don't use the Display: False, instead put the input inside an IF and if the condition resolves to False, the input will not be in the form and the Form will be valid.

What I would like to understand is the reason behind this decision and how this works.

I understand that if the input is not visible, the validation has "nowhere" to go, as there is no way to inform the user something is wrong, nor the user would be able to solve the situation (or shouldn't have a way). So, it makes sense to call the action.

But at the same time, if the input is hidden, I am probably not concerned with it (maybe a client side mechanism to control visibility of inputs that will be necessary or not, but that I want to be mandatory if visible), and the fact that it makes the form invalid is annoying, as I will have to setup extra logic server side to check which input is causing the problem to solve a situation that is not really a situation.

Also, how is this possible? Is the validation method looking solely to VISIBLE input valid properties, and not to the Form invalid property? This kind of make sense, as the Form itself is not really mandatory, as validation still works without a Form, that is more like a way to check validation at a single point (Form.Valid) with a nice repository to the input values (Record).

Well, like I said, more curious than concerned.

Eduardo Jauch


This falls into the fine points of HTML... and whether a control is rendered... or not.

This may even be a bug in OS... but it depends on how OS views (get it?) rendered, but not shown, elements.

Also, your example setting Display=False is operating on a Container... not the Control... which might have very subtle implications. 

This whole question also depends on whether you want to USE the "hidden" control.

If you do NOT want to use the control, then set the Container Display to False.  And then set the Control Visible property to False.  This results in the control not being rendered.  If the control isn't there, then Form Validation cannot act upon it... and the Form is valid.

If you want to use the control, then either OS will need to adjust it's "Validation" formula to ignore "hidden" controls... or you'd need to fake out the Validation and put in a default value for the control.  You could also test that control at the time of submission and provide a value then.

For very precise control, OS could add another property... Do Not Validate if Hidden.