/\S+@\S+\.\S+/.test(value), 'Recipient email');
isValid &&= validateField(recipientNameField, value => value !== '', 'Recipient name');
isValid &&= validateField(messageField, value => value !== '', 'Message');
// Validate sendOn date
const sendOnValue = sendOn.value.trim();
const currentDate = new Date();
const maxDate = new Date();
maxDate.setDate(currentDate.getDate() + 90); // 90 days from now
if (sendOnValue === '') {
// If the date is blank, remove invalid class and hide error message
updateFieldStyle(sendOn, true);
sendOnErrorElement.classList.add('hidden');
} else {
if (!isValidDate(sendOnValue)) {
sendOnErrorElement.classList.remove('hidden');
sendOnErrorElement.querySelector('.error-msg').textContent = 'Invalid date format. Please use mm-dd-yyyy.';
updateFieldStyle(sendOn, false);
isValid = false;
} else {
const sendOnDate = new Date(sendOnValue);
if (sendOnDate < currentDate.setHours(0, 0, 0, 0) || sendOnDate > maxDate) {
sendOnErrorElement.classList.remove('hidden');
sendOnErrorElement.querySelector('.error-msg').textContent = 'Send on must be within 90 days from now.';
updateFieldStyle(sendOn, false);
isValid = false;
} else {
properties['Send on'] = formatDate(sendOnValue);
updateFieldStyle(sendOn, true);
sendOnErrorElement.classList.add('hidden');
}
}
}
properties['__shopify_offset'] = timezoneOffset;
properties['__shopify_send_gift_card_to_recipient'] = giftCardCheckbox.checked ? 'on' : 'off';
if (!isValid) {
return; // Stop if any validation failed
}
}
// Add the item to the cart
Cart.add({
id: variant.id,
properties: properties,
});" role="button" aria-label="add-to-cart">
Add to Cart
/\S+@\S+\.\S+/.test(value), 'Recipient email');
isValid &&= validateField(recipientNameField, value => value !== '', 'Recipient name');
isValid &&= validateField(messageField, value => value !== '', 'Message');
// Validate sendOn date
const sendOnValue = sendOn.value.trim();
const currentDate = new Date();
const maxDate = new Date();
maxDate.setDate(currentDate.getDate() + 90); // 90 days from now
if (sendOnValue === '') {
// If the date is blank, remove invalid class and hide error message
updateFieldStyle(sendOn, true);
sendOnErrorElement.classList.add('hidden');
} else {
if (!isValidDate(sendOnValue)) {
sendOnErrorElement.classList.remove('hidden');
sendOnErrorElement.querySelector('.error-msg').textContent = 'Invalid date format. Please use mm-dd-yyyy.';
updateFieldStyle(sendOn, false);
isValid = false;
} else {
const sendOnDate = new Date(sendOnValue);
if (sendOnDate < currentDate.setHours(0, 0, 0, 0) || sendOnDate > maxDate) {
sendOnErrorElement.classList.remove('hidden');
sendOnErrorElement.querySelector('.error-msg').textContent = 'Send on must be within 90 days from now.';
updateFieldStyle(sendOn, false);
isValid = false;
} else {
properties['Send on'] = formatDate(sendOnValue);
updateFieldStyle(sendOn, true);
sendOnErrorElement.classList.add('hidden');
}
}
}
properties['__shopify_offset'] = timezoneOffset;
properties['__shopify_send_gift_card_to_recipient'] = giftCardCheckbox.checked ? 'on' : 'off';
if (!isValid) {
return; // Stop if any validation failed
}
}
// Add the item to the cart
Cart.add({
id: variant.id,
properties: properties,
});" role="button" aria-label="add-to-cart">
Add to Cart
Notify Me When Available
Please Select Options
Sold Out