Where validation is performed?

Where validation is performed?

Could someone try to explain me the difference between Client & Server and Server validations?

I read the “Validate End-User Typed Values” help topic but I don’t get it.

Thank you,
Hello Mário,

I'm not so sure what your doubt is, but I'll try to explain the behavior of the several options without repeating the help topic you mention.

When you click a button on an OutSystems application the following occurs: if the validation is set to "Client & Server" a Javascript (client) validation is made. This Javascript validation checks things like if the mandatory inputs are filled and if the datatype appears to be correct. If the Javascript validation fails, the error message is shown and the form is not submitted to the server, i.e. the screen action is not executed. If the Javascript validation is OK, there will be a "Server" validation.

If the validation is set to "Server" the inputs are always submitted to the server. All checks are made server side before the execution of the screen action. Input runtime properties are set with information if the input is valid and what the error message is. You can then change your logic to handle these errors or even make additional checks and add new errors to the form (check the "Persistent Web Screen State and Input Validations" video in http://www.outsystems.com/NetworkForums/viewtopic.aspx?TopicId=2874 for an example on how to use this feature).

If the validation is set to "(none)", all inputs are considered valid even if they're not.

If you're wondering what happens to variables, if an input is invalid its associated variable will have the default value for that datatype. E.g. if you set an integer input to "aaa" and click a button with validation set to "Server" the value of the variable in the screen action will be 0.

Hope this helps,
when you have a button (or link) with 'Client & Server' validation, the inputs are validated on the client side, and if any of them is invalid the request is aborted, so it never reaches the server.

If your button has 'Server' validation, the request is always submitted, and the inputs are validated before your screen actions are executed, so that you have the widgets' runtime properties (Valid and ValidationMessage) correctly filled to use in any logic you may have in your screen action.

Visually, the impact of validating client or server side is the same, i.e. the validation message is displayed and the styles are affected.

The validations automatically performed on client and on server side have exactly the same behavior, they validate the inputs according to their mandatory property and variable type.

Note that if the client side validation is successful, the request is submitted, so it will also be validated server side (hence the name 'Client & Server'), so you can still do further validation logic on your actions.