Hi, 

I'm doing the Booking Assignment and i want to prevent the user to click the buttons of "Get Available Room" and "Book Room" if he input the number of adults or children inferior to ZERO. 

So i tried to enable the button through his properties doing a if to validate the value of both inputs. Then i realized that won't work, in this case i'm wondering if this validation occur only in server side. 


Then i was trying to implement some JavaScript but i can't understand where to put it. 

Solution

Hi Ruben,

that condition that you added to button enabled is only checked when the button is rendered. so basically you need to force him to render again. yes you can use js but since you are still learning I recommend you to add an onchage action to the inputs of number of adults and number of children that does an ajax refresh to the buttons you want to disable.

Regards,

Marcelo

Solution

Hi Ruben,

I have the same opinion than Marcelo.


Just one thing: you don't need to place if(......,.....,False) in the Enable property. You just need to put the conditions that are true to enable the button: 

Bookingform.Record.Booking.NumberOfAdults > 0 and Bookingform.Record.Booking.NumberOfChildren > 0

Regards,

Ricardo

Marcelo Ferreira wrote:

Hi Ruben,

that condition that you added to button enabled is only checked when the button is rendered. so basically you need to force him to render again. yes you can use js but since you are still learning I recommend you to add an onchage action to the inputs of number of adults and number of children that does an ajax refresh to the buttons you want to disable.

Regards,

Marcelo

Hi Marcelo,

Thanks for the quick reply. I'm going to follow your advice cause it works for this issue but i'm struggling with JS matter. I already see some tutorials of Master Class JavaScript, isn't easy to understand that subject. 

Regards,

Marcelo 12 ;)


Ricardo Pereira wrote:

Hi Ruben,

I have the same opinion than Marcelo.


Just one thing: you don't need to place if(......,.....,False) in the Enable property. You just need to put the conditions that are true to enable the button: 

Bookingform.Record.Booking.NumberOfAdults > 0 and Bookingform.Record.Booking.NumberOfChildren > 0

Regards,

Ricardo

Hi Ricardo,

Yap i see it now. 

Bookingform.Record.Booking.NumberOfAdults > 0 and Bookingform.Record.Booking.NumberOfChildren > 0

Returns already a boolean.

Thanks for the reply.


Hi Rúben,

Yes JS is a more advance subject. When you find a use case where you really can't use Outsystems functionalities make a new post on forum asking for help and for sure someone will answer. If I see it I will do it myself.

Regards,

Marcelo

Rúben Oliveira wrote:

Hi, 

I'm doing the Booking Assignment and i want to prevent the user to click the buttons of "Get Available Room" and "Book Room" if he input the number of adults or children inferior to ZERO. 

So i tried to enable the button through his properties doing a if to validate the value of both inputs. Then i realized that won't work, in this case i'm wondering if this validation occur only in server side. 


Then i was trying to implement some JavaScript but i can't understand where to put it. 

Hi,

Javascript is an advanced topic. I think you should follow the Ricardo Pereira and Marcelo Ferreira said. Once you have a good hands-on experience you can go through the advanced topics and try.

All the best!!