Confuse about the logic checking

CleanShot 2023-06-29 at 14.27.57@2x
I have a javascript code in the picture above. I wanna use memberIdExists to check wether the member in my database before user submit the form. However, no matter the value of the memberIdExists is true or false it will always execute the if section. As the console shows below the I print the value before execute the code, the value is false but it still execute in if section.

Please help me! I am struggle with it for a long time.

Your IF statement is checking for the existence of memberIdExists (the entity itself) not that the value of memberIdExists is populated (the .value that you logged to the console), you should check memberIdExists.value not memberIdExists

eg:

if (memberIdExists.value === true) { add_booking.trigger(); }

1 Like