const formTitle = document.getElementById('form_title'); const formDescription = document.getElementById('form_description'); const formDisclaimer = document.getElementById('form_disclaimer'); const emailInput = document.getElementById('email_input'); const phoneNumberInput = document.getElementById('phone_number_input'); const submitButton = document.getElementById('submit_button'); const closeButton = document.getElementById('close_form_button'); const popupWrapper = document.getElementById('popup_wrapper'); phoneNumberInput.style.display = 'none'; formDisclaimer.style.display = 'none'; closeButton.style.display = 'block'; // Function to validate the email using a regular expression function isValidEmail(email) { const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; return emailPattern.test(email); } function isValidUSPhoneNumber(phoneNumber) { const phonePattern = /^(?:\+1[-.\s]?|1[-.\s]?)?\(?(\d{3})\)?[-.\s]?(\d{3})[-.\s]?(\d{4})$/; return phonePattern.test(phoneNumber); } function closeForm() { popupWrapper.classList.remove("show"); } function submitForm() { const emailError = document.getElementById('email_error'); const phoneNumberError = document.getElementById('phone_number_error'); const formError = document.getElementById('form_error'); // Clear previous errors emailError.style.display = 'none'; phoneNumberError.style.display = 'none'; formError.style.display = 'none'; // Validate inputs let isValid = true; if (emailInput.style.display !== 'none') { if (!isValidEmail(emailInput.value)) { emailError.style.display = 'block'; isValid = false; console.log('email not valid'); } if (!isValid) { return; } const data = { "email": emailInput.value.trim(), "listId": 5122015 } fetch('https://us-central1-fd-swap-app-prod-1.cloudfunctions.net/api_v2/v1/marketing/conferenceSubscribe', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => { if (response.ok) { // Hide the email emailInput.style.display = 'none'; phoneNumberInput.style.display = 'block'; formTitle.textContent = 'Complete your signup'; //formDescription.textContent = ''; formDisclaimer.style.display = 'block'; phoneNumberInput.focus(); submitButton.textContent = 'Join the list'; posthog.capture( '$set', { $set: { closed_email_popup: 'true' } } ); } else { // Highlight the input fields in red and show error text formError.textContent = 'There was an error submitting the email 1'; formError.style.display = 'block'; } }) .catch((error) => { // Highlight the input fields in red and show error text formError.textContent = error; formError.style.display = 'block'; }); } else { if (!isValidUSPhoneNumber(phoneNumberInput.value)) { phoneNumberError.style.display = 'block'; isValid = false; console.log("Phone number not valid"); } if (!isValid) { return; } const data = { "email": emailInput.value.trim(), "phoneNumber": phoneNumberInput.value.trim(), "listId": 5122015 } fetch('https://us-central1-fd-swap-app-prod-1.cloudfunctions.net/api_v2/v1/marketing/conferenceSubscribe', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => { if (response.ok) { // Hide the email emailInput.style.display = 'none'; phoneNumberInput.style.display = 'none'; submitButton.style.display = 'none'; closeButton.style.display = 'block'; formDisclaimer.style.display = 'none'; formTitle.textContent = 'Signup successful!'; formDescription.textContent = 'You will get exclusive notice on new rewards, Take Back deals, and more!'; } else { // Highlight the input fields in red and show error text formError.textContent = 'There was an error submitting the phone number'; formError.style.display = 'block'; } }) .catch((error) => { // Highlight the input fields in red and show error text formError.textContent = 'There was an error submitting the phone number'; formError.style.display = 'block'; }); } }
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Contact us

Interested in selling Take Back Bags or running ReNewItCash Rewards? Email us at partnerships@ReNewIt.io.

Ambassador Program: ambassadors@ReNewIt.io

Creators & Social Collabs: creators@ReNewIt.io
Press: press@ReNewIt.io

Select one...
Thank you for getting in touch. You'll receive a response from our team shortly!
Oops! Something went wrong while submitting the form.

business opportunities

RENEW IT UK APP LTD
Company number : 16865469
Registered office address : 82a James Carter Road, Mildenhall, England, IP28 7DE

Interested in selling Take Back Bags or running ReNewItCash Rewards? Email us at partnerships@ReNewIt.io.

Ambassador Program: ambassadors@ReNewIt.io

Creators & Social Collabs: creators@ReNewIt.io

Press: press@ReNewIt.io