Validate all inputs together

There was a discussion regarding this topic - https://www.wix.com/corvid/forum/community-discussion/check-the-validity-of-all-input-in-one-go

Here is a test, for validating a page that only has text inputs.
If all inputs are valid (their only requirement is to be filled), then the button should be enabled.
This page has only 3 input boxes, but it seems like only one of the boxes triggers this condition.
Here is the code:

let textElements = $w(“TextInput”);

textElements.onChange((event) =>{
if (textElements.validity.valid){
$w(‘#button1’).enable();
}
else {
$w(‘#button1’).disable()
}
})

The code basically checks (hopefully), whenever there is a change in any of the text inputs, if all inputs are valid.
What could possibly be the problem? This is a single simple case, but it can help with understanding the rule.

Thank you!

Have you read the Wix page about validation and checked out the Wix example about it too as that can help you.
https://support.wix.com/en/article/corvid-about-validating-user-input-with-code
https://www.wix.com/corvid/example/custom-validations

Also, simply use the search function on this forum as validation has been asked many times before…
https://www.wix.com/corvid/forum/community-discussion/enable-a-form-submit-button-if-all-input-elements-are-valid
https://www.wix.com/corvid/forum/community-discussion/text-field-validation

I have been through all that before, and i have posted a link to the closest discussion i could find about the topic.
I basically wanted to know if you can run a validity check on all elements of same type.
In the link i’ve attached to my original post, our dear Israel of Wix explained that you can use for example the property $w("TextInput) to run through the entire array of text input elements.
But, in my very simple test it didn’t work, and that is why I’ve tried my luck with the supporting Corvid community.

@assaf_duv See the discussion about $w() for searching for components by Type. This works - I’ve done it myself.

Make sure you are using the correct component type and that the statement syntax is correct. BTW - you left out the closing quotes. It should be $w(“TextInput”).