Hello,
I want to make a sign-up page but only allow the user to successfully sign-up if they put the correct code in. This is my code:
import wixLocation from 'wix-location';
import authentication from 'wix-users';
$w.onReady(function () {
// Add your code here
});
export function button1_click(event, $w) {
const codeInput = $w('#codeInput');
if (codeInput.value === 'givencode') {
authentication.register($w("#emailInput").value, $w("#passwordInput").value)
.then(() => {
// Registration successful, redirect user to another page
wixLocation.to("/success");
})
.catch((error) => {
// Registration failed, show error message
$w("#errorMessage").text = error.message;
});
} else {
// Incorrect code, show error message
$w("#errorMessage").text = "Incorrect code.";
}
}
But when I preview it, and purposefully put the incorrect code in, it still signs up the person and does not display the error message. Am I not displaying the error code correctly?