If someone is signing up for my website with an email that is already taken, I want an error message that says "Email is already taken" to show up on the light box where my signup form is. I checked off the collapsed option for the text, but I cannot get it to show up when an already taken email is inputted. Here is my code:
import wixData from "wix-data"; $w.onReady(function (){ // nothing to do here }); export function button2_click(event) { //Add your code for this event here: $w('#button2').onClick(function(){ let email = $w('#input2').value return wixData.query("Members/PrivateMembersData") .eq('loginEmail', email) .find() .then((results)=> { if(results.items.length > 0) { $w('#text15').expand() } }); }); }
Button2 is the submit button and text15 is the error message. Can anybody tell me what I am doing wrong?
You are defining an onClick() event handler inside of another onClick() event handler. Your button2_click() function should look something like this:
export function button2_click(event) { let email = $w('#input2').value return wixData.query("Members/PrivateMembersData") .eq('loginEmail', email) .find() .then((results)=> { if(results.items.length > 0) { $w('#text15').expand() } }); }