Enable Button if enough words are inputted in Text Box

Guys thank you very much for the info.! and yes I meant “characters”, sorry about that!

I have tried both suggestions but still I need to CLICK somewhere else to make the button enable…The following is my code using @tony-brunsman 's suggestion, in case I’ve put some codes in a wrong place.


import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;
import wixWindow from ‘wix-window’;

export function password_keyPress(event) {
console.log(event);
DisableEnable(event);
}

function DisableEnable(event) {
let realValue = “”;
let fadeOptions = {
“duration”: 500,
“delay”: 0
};
switch (event.key) {
case “Shift”:
case “Control”:
case “Alt”:
case “Meta”:
// these keys were pressed, so don’t add event.key to the realValue variable.
realValue = event.target.value;
break ;
case “Backspace”:
let PrevValue = event.target.value;
let NewLength = PrevValue.length - 1;
realValue = PrevValue.slice(0, NewLength);
break
default :
realValue = event.target.value + event.key;
break ;
}

if (realValue.length >= 4) {
$w(‘#regenter’).enable()
$w(“#regenter”).onClick(() => {
let email = $w(“#email”).value;
let password = $w(“#password”).value;
wixUsers.register(email, password)
.then((result) => {
let resultStatus = result.status;
wixWindow.lightbox.close();
wixLocation.to(“/account/signup”);
})
. catch ((err) => {
console.log(err);
$w(“#error”).show(“fade”, fadeOptions);
});
});
} else {
$w(‘#pwerror’).show(“fade”, fadeOptions)
$w(‘#regenter’).disable();
}
}

$w.onReady( function () {
$w(“#password”).onChange(DisableEnable);
});