Hi there!
I am really struggling with this issue:
I have an input field (input 10) where the user has to enter an activation code that he/she received. I have a database (called CardActivationCodes) where the activation codes are stored and matched to the email adresses.
With onChange of input 10 I would like to get the logged-in-users email adresse and confirm that the activation code in input 10 matches the code I have for this email adress in the database.
The problem: It worked with my test email adress but it does not work for any other email adress. And I can not figure out why… Does anyone spot an issue in the code?
I checked the Field-Key about 20 times. I know that the problem must be at the first steps of the query part…
Thanks so much for your help!
export function input10_change(event) {
//Add your code for this event here:
let activationcode = $w("#input10").value
wixUsers.currentUser.getEmail().then((email) => {
wixData.query("CardActivationCodes")
.eq("emailAddress", email)
.find()
.then(res => {
if (res.length === 0) {
}
else
if (res.items[0].cardActivationCode === $w('#input10').value) {
$w("#button6").enable();
$w("#checkbox1").enable();
$w("#text60").hide();
}
else {
$w("#text60").show();
}
})
}
).catch((err) => {
let errorMsg = err;
})
}