I have this code to validate an email:
export function email_blur(event, $w) {
console.log(“--------------------------”);
console.log(“email : “,$w(”#email”).value)
let email = $w(“#email”).validity;
if(!email.valid ) {
console.log(“–email.valid false”,email.valid);
$w(“#emailError”).show();
$w(“#email”).focus();
}else{
console.log(“–email.valid true”,email.valid);
$w(“#emailError”).hide();
}
}
if i enter an invalid email it show the error, but if i then, enter a correct one valid still ‘false’, if i try again with any change it turns to ‘true’, like if it where delayed, this is the output for ‘false’,‘true’, ‘true’:
email : test
–email.valid false false
email : test@test
–email.valid false false
email : test@test
–email.valid true true
Any idea why it behaves like this? what i’m doing wrong?