I have a multi-state box that works except that I need the button to be enabled/disabled based upon whether or not the fields are filled out. If you could please let me know what I need to add to my code, I would greatly appreciate it! Thank you for your help!
Here is my code:
So the real first question is, if its faster to build it dynamic or hardcoded, all depends on how many fields you are talking about.
if hard coded you can make a 2D array (array in an array)
Where the inner array contains all the wixelementIDs of the fields for each stage
This way you are able to write a loop that says uses your
var allFieldsAreValid = true;
2DArrayOfElements[indexCurrent].foreach(element => {
if(!element.valid)
{
element.updateValidation();
allFieldsAreValid = false;
}
})
if(allFieldsAreValid)
{
goToState(MultiState,next)
}
loops through each element with a
element.valid check
If one fails you simply run element.updateValidation() and do not call goToState yet.
Dynamic you instead have to at every stage make the code prepare a array of elementID’s
this means upon loading a new stage you pick the stages container and find all the children, i would suggest you use a wixElementID identifier like naming them all “input” and filtering for those elements only with input in their ID.
Save them all in an array and repeat above.
I wish I had the ability to understand any of what you said but unfortunately, I am a novice at best. This is my first time handling code. I copy and pasted the code you provided and it did not work but I am assuming that I needed to modify it in some way.