Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
I want to add validation for customer email domain in my javascript frontend code like the validtion there is in the checkout page for the customer email domain. how can i get this function? there is api?
This topic has already been discussed before on the Shopify community. If you could spend your valuable time on this conversation, then I believe you can get an answer.
If you don't find your answer, then get back to me. I would like to guide you further.
Thanks for the reply, I read the answer but I don't want to use a specific pattern.
I want the logic like on the checkout page that checks for every domain that can be given to it whether it is a real domain or not!
Is this possible?
Based on my research, unfortunately, Shopify doesn't provide a direct API for accessing their internal email domain validation logic that's used in the checkout. However, I can help with a third-party service, DeBounce Integration by integrating the DeBounce into your Shopify forms API and adding your domain to the approved domain lists.
Here is the detailed info: https://debounce.io/integrations/shopify/
You can explore this code for further info.
async function validateEmailWithAPI(email) {
try {
const response = await fetch(`https://api.debounce.io/v1/?api=${YOUR_API_KEY}&email=${email}`);
const result = await response.json();
return result.debounce.result === 'Safe';
} catch (error) {
console.error('Email validation error:', error);
return false;
}
}
I hope this could helps.