Custom Validations on multiple input fields in a form
Application Type
Reactive

In a signup  form user enters several values I want to check that the user doesn't enter duplicate email,mobile number or username.

Hi! 

I suggest you follow the course 

https://www.outsystems.com/training/paths/18/becoming-a-reactive-web-developer/ 

for a complete answer. 

Stay safe 

Graça

I have already completed the course but couldn't find the solution to the problem I am facing.

Hi Atishay,

I assume that you want to check if newly entered email, mobile number or username is existing in database right?

If so, you need to add a server action to check it. 

Inside the server action you can use aggregate with filter [Entity].Username = EnteredUsername or [Entity].Mobile = EnteredMobile or [Entity].Email = EnteredEmail.

If result list of aggregate is not empty then there is duplicated (already existed) username or mobile or email.

That is the idea, you can custom it like just check 1 condition at a time like 1 aggregate with filter username, 1 aggregate with filter mobile...

Hope it helps,

Khuong 

I tried with the above idea but even if data entered in one of the field is duplicate all the three fields are marked as invalid

To have a field marked as invalid requires you to set the widget.valid attribute to false.

Best is to check where you do this and fix your code.


I think you have created 1 client action for all 3 widgets on the change/blur event, am i right?

I would create 1 different client actions for each widget update event, but it will work either way if you only set the widget false when the variable that is attached is considered double in your server validation action.

Don't forget to set it to true again if its valid ;)

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.