Custom Registration: Input Validation - Email Exists Error Message

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!


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) => { “/confirmation” );
. catch ((err) => {
let errorMsg = err;
$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.

1 Like

So here are the correct opposites to use in code:

Hide > Show

Collapse > Expand

If you mix match, the code won’t work. So try collapsed on load for your error message. (You can read this same suggestion within that same text line.)

P.s. Thanks for watching my tutorials!