If you have a text input field and set its type to email, the validity check does not work if you do it in the keyPress event. What ever the last value was is what is presented.
Even an asynchronous call from the event handler fails to get the proper value.
export function emailInput_keyPress(event) {
if (event.key === ‘Enter’) {
console.log(‘Validity check on Enter:’, $w(‘#emailInput’).valid)
testVaild_click()
getEmailValid()
}
}
export function testVaild_click(event) {
console.log(‘Validity check on testVaild_click:’, $w(‘#emailInput’).valid)
}
function getEmailValid() {
console.log(‘Validity from getEmailValid:’,$w(‘#emailInput’).valid)
}
Enter a valid email, then click the testValid button and note the output.
Then press Enter in the input field. It will show the same output
Edit the email and make it invalid and hit Enter. Note the output still says it is valid.