I need to validate a form before submit, but i need to know who’s sending. Actual DB doesn’t show the name of user, only id. Then i need to create a kind of email validation in my form where a registered user put his email and the formula says if its match with his registered email or not before send the form.
Anyone has this formula or know how can i do this?
Hello Fernando,
It would look something like this
import wixData from 'wix-data';
...
wixData.query(collectionName)
.eq("email", userEmail)
.find()
.then((res)=> {
if(res.length>1) { //user found
//whatever you want to happen after validation.
}
});
Best,
Majd
I am trying this very thing and the code errors for the query due to auth (user does not have read permissions on the collection). How am I supposed to query a collection while a “non member” is registering?
Hello Sharon.
You might want to look into collection permissions and editing them, here:
https://support.wix.com/en/article/how-to-edit-permissions-for-a-database-collection
Goodluck,
Majd
Hello Majd Qumseya,
I read the code you wrote and I wonder how can I change it to use for verify if an email is already present in the collectionDB before register a new user.
Can you help me, please?
Good bye,
Marco