Hi Kana,
It turns out that the KeyPress event object has an intuitively unexpected behavior, but there is a way to deal with it. Have a look at this annotated screen shot:
Understanding this, here is some code to make your form work:
export function password_keyPress(event) {
console.log(event);
DisableEnable(event);
}
function DisableEnable(event){
let realValue = "";
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()
} else {
$w('#regenter').disable();
}
}
