Hi. I have a custom registration form set up and what to display an error message is a registered user try’s to register again. Below is the code I have however I can’t get it to work. I have the text error message hidden on load. Any help as to where I am going wrong or what I am missing would be appreciated. Thanks!
Code:
import wixUsers from ‘wix-users’ ;
import wixLocation from ‘wix-location’ ;
import wixWindow from ‘wix-window’ ;
$w.onReady( function () {
$w( ‘#registerButton’ ).onClick( function (){
let first = $w( “#firstName” ).value;
let last = $w( “#lastName” ).value;
let email = $w( “#email” ).value;
let password = $w( “#password” ).value;
wixUsers.register(email, password,{
contactInfo: {
“firstName” : first,
“lastName” : last
}
})
.then((result) => {
wixLocation.to( “/confirmation” );
})
. catch ((err) => {
let errorMsg = err;
console.log(errorMsg);
$w( ‘#emailExists’ ).expand(); // You can delete this line if you are not going to add an error message. Use a regular text element set to ‘collapse on load’ from the Properties Panel.
});
})
})