how to write the code so that the "submit" button is not active until the required fields are filled in the form?
photo, this is just an example.
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
@Di First, don't enable the send button by default.
Then , try this:
$w.onReady(function () { $w("#name").onChange(() => updateSubmitButtonStatus()) $w("#email").onChange(() => updateSubmitButtonStatus()) $w("#phone").onChange(() => updateSubmitButtonStatus()) $w("#problem").onChange(() => updateSubmitButtonStatus()) $w("#tellUs").onChange(() => updateSubmitButtonStatus()) }); function updateSubmitButtonStatus() { if (($w("#name").valid == true) && ($w("#email").valid == true) && ($w("#phone").valid == true) && ($w("#tellUs").valid == true)) { $w("#push").enable() } }
HI there 👋🏻 I do something similar on my site. Below is the basic structure that I use, you can adapt it to your needs.
$w('#email1, #password1').onChange(() => { if ($w('#email1').valid && $w('#password1').valid) { $w("#yourButton").enable(); } else { $w("#yourButton").disable(); } })
Good luck!