Input validations

Input validations

  

Hi,

I'm doing Developing OutSystems Web Applications, online training and in the exercise is needed create movie details screen and person details screen.
On mandatory fields(in Web Screens and in Entities) in these 2 screens, validations on mandatory fields are not made(null values are submitted) and these mandatory fields  don't have default values.

Anyone knows what is wrong?


Thanks.

Hi Ana,

It's difficult to tell without you telling us what you did.

Hi Kilian,


I created a web screen with 2 mandatory fields, as showned in the attached image. When I click on Save button, after clear title and year fields the values are submitted with null values. None validation is done. Do you the reason?

Thanks.

Hi Ana,

The reason is that the button has Validation set to Server. This means that your logic is supposed to check whether the value is ok (and set the IsValid of the input to False, refresh the screen etc.). If you want the check before the server is called, you need to set it to Client & Server validation.

Kilian Hekhuis wrote:

Hi Ana,

The reason is that the button has Validation set to Server. This means that your logic is supposed to check whether the value is ok (and set the IsValid of the input to False, refresh the screen etc.). If you want the check before the server is called, you need to set it to Client & Server validation.

Hi Killian.

Thanks for your help. I thougth that shouldn't be necessary test if "Form.Valid" on server side, because this type of validations(mandatory fields) should be validated by default on Outsystems Plataform.

Thanks again. It worked!


Solution

Hi Ana,

If you set the validation to "(none)", the Platform doesn't generate a validation message in the HTML. If you set it to Client & Server, it adds JavaScript to the button to check the mandatory input fields, and show the validation message if they're not supplied. If you set it to Server, the platform expects you to check the input yourself (e.g. not only for whether it's supplied at all, but also other validations, e.g. range), set the Valid to False and refresh the screen, so that the validation messages are shown.

You definitely don't need to check the Form.Valid server side, but you can do so if you want to perform additional checks.

Solution

Kilian Hekhuis wrote:

Hi Ana,

If you set the validation to "(none)", the Platform doesn't generate a validation message in the HTML. If you set it to Client & Server, it adds JavaScript to the button to check the mandatory input fields, and show the validation message if they're not supplied. If you set it to Server, the platform expects you to check the input yourself (e.g. not only for whether it's supplied at all, but also other validations, e.g. range), set the Valid to False and refresh the screen, so that the validation messages are shown.

You definitely don't need to check the Form.Valid server side, but you can do so if you want to perform additional checks.

Hi, 

I changed "Save" button validation to "Client & Server" and it worked fine, without Form.Valid on server side. It's more simple like that for mandatory fields.

Thanks you



Hi Ana,

Great to hear it works! Could you please mark my answer above as Solution, so the topic is marked as such? Thanks!