button.enable propery not working

button.enable propery not working

  
Button enable property doesn't work when we have two or more valid condition added to it. Let me try to provide a case -
input box 1
input box 2
btnok
Now, btnok is enabled only when input box 1.valid and input box 2.valid

On change of input box 1
if value is false, set input box 1.valid = false error message = "error message" -> refresh input box 1 -> refresh btn ok
if value is true, set input box1.valid = true error message = "" -> refresh input box 1 -> refresh btn ok

On change of input box 1
if value is false, set input box 2.valid = false error message = "error message" -> refresh input box 2 -> refresh btn ok
if value is true, set input box2.valid = true error message = "" -> refresh input box 2 -> refresh btn ok

now, when any of the input box is valie, button get enabled. Even though the other input box is marked as invalid.
For e.g. input box 1 is invaild -> application displays error and btn ok is disabled
then I enter the valid value in input box 2 -> btn ok gets enabled!

I don't know what I am missing. Is refreshing the button widget ignore the invalid property!
Do let me know if you seek any further details to help me out.

Hi Vivek,

It seems that:
  1. You change the input1, the OnNotify1 runs and you set the input1.valid to false
  2. You change the input2, to OnNotify2 runs, but for your surprise if you check the input1.valid it is set to true.
So my suggestion would be to make both inputs use the same OnChange action. In that action check and set input1.valid, then check and set the input2.valid, refresh the inputs and refresh the button
Hi Joao,

Thank you for the reply. We did exactly that after our first approach didn't work. However, this migth not be a practical solution if we have the validation on let's say 7 fields.
We will end up validating everything even though only one field is being changed.

Can you guide on how can we utilize the java script to implement client side validation on fields (like, value should be greater than 0, value 1 > value 2 etc.)

Thank you
Hi,

I've never tried to implement custom validators on javascript, but I've found this post that explains how to do it.
Unfortunately the post is a bit old, so you will have to fiddle around with the javascript to ensure it works properly.

I've also found this component on forge that implements validations for things like credit cards, emails...looks like it provides functionality to validate on client or server, so you can just explore how it does. This component is quite recent, since it was implemented using the OutSystems Platform 8.