Hi all, new to velo. I've been working on having a form save a username and email to a collection as long as the username is unique within the collection. Thus I went over the documentation to find a function called: onWixFormSubmit() my issue is that I'm unable to test this as when I publish and run the website I get an error in the console saying:
TypeError: $w(...).onWixFormSubmit is not a function
My function will be shown below:
$w("#registrationForm1").onWixFormSubmit((event) => { let email=event.fields[0].fieldValue; let username=event.fields[0].fieldValue; //$w('#username').value return wixData.query("UsernameEmail") .eq("Username", username) .find() .then( (results) => { if(results.length!=0){ console.warn("Username already in use") return false; //wixLocation.to(wixLocation.url); } else { let payload = { "Email": email,//$w('#input2').value "Username": username//$w('#username').value } wixData.save("UsernameEmail",payload) .then( (results) => { let item = results; //see item below } ) .catch( (err) => { let errorMsg = err; } ); } } ) //return event.fields; });
#registrationForm1 is the name of my wix form.
Any insight would be greatly appreciated thank you so much.
Hi @Matthew Mierzwa
Are you trying to add an event handler to the Wix Registration form?
If you want to listen to member signup event, check out the events under wix-members module for backend.
It is not possible to add a listener to the frontend signup form.
Is it inside $w.onReady ? Is inside another event handler?