Dropdown .Valid fails on first selection

I have a dropdown I populate via code (not directly connected to a data collection. See lines 124 & 127.

Then I have an onChange event where I first check if the field is valid. See the second image.
The data population seems to work as the values are present. I start off with no value in the drop-down pre-selected.

PROBLEM : The weird part is, when a value is selected, it fails the validation check saying the value is missing. I can log to the console the value of the drop-down right before checking if it is valid and the value is most certainly there.

Then to make it even weirder, if you toggle the drop-down options, everything works. So when the very first selection is made, it for some reason thinks the value is missing using .valid. I’ve even toggled to another option and then gone back to the first one and it will work. See the video.

Ideas…

Hi Neff :raised_hand_with_fingers_splayed:

Instead of using the valid method on the dropdown menu, use the selectedIndex , or the value method, I’ll give you an example on both of them.

Option #1: Selected Index.

if ($w('#ddRoomTyped').selectedIndex !== undefined) {
    // Run your code here
}

Option #2: Value.

if ($w('#ddRoomTyped').value !== '') {
    // Run your code here
}

Either ways, it should work just fine.


Hope this helps~!
Ahmad

Thanks for the workaround! I’ll give those a try.

However, the .valid should work, no? I feel like there is a bug with it not registering the selected value in that function on the first select.

The validation process is buggy, it mostly count on the requirement of the field (required or not), I prefer to use these methods in my projects, it’s %100 guaranteed to work, I can’t take any chances.

If you need further assistance don’t hesitate to reply.