
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
mailchimp-submitter
Advanced tools
yarn add mailchimp-submitter
# or
npm install mailchimp-submitter
Create your HTML form
<!-- Ensure you add data-mc to your form to mailchimp-submitter will find it -->
<form data-mc="true" id="my-form">
<!-- Add required fields including: 'project', 'datacenter', 'u', 'id' -->
<input type="hidden" name="project" value="MY-PROJECT-NAME" />
<input type="hidden" name="datacenter" value="us7" />
<input type="hidden" name="u" value="XXXXXXXXXXXXXXXXXXXXXXXXX" />
<input type="hidden" name="id" value="XXXXXXXXXX" />
<!-- Add mailchimp fields -->
<input type="email" name="EMAIL" />
<input type="text" name="FNAME" />
<input type="text" name="LNAME" />
<button>Subscribe</button>
</form>
Import functions in your JavaScript and initialize Mailchimp Submitter
import MailchimpSubmitter from 'mailchimp-submitter'
// Initialize mailchimp submitter on your forms with data-mc="true"
MailchimpSubmitter()
MailchimpSubmitter({
// Optional callback before submitting form to Mailchimp.
// Return false in this callback to cancel the form request (IE. validation).
beforeSubmit: _formEl => {
const isValid = validateForm()
return isValid
},
// Optional callback after Mailchimp response
callback: (_formEl, resp) => {
if (resp.result === 'success') {
alert('Successfully subscribed')
} else {
alert('Error: ' + resp.msg)
}
},
})
const myForm = document.getElementById('my-form')
myForm.addEventListener('mcBeforeSubmit', () => {
console.log('Submitting form...')
})
myForm.addEventListener('mcCallback', ({ detail: resp }) => {
if (resp.result === 'success') {
alert('Successfully subscribed')
} else {
alert('Error: ' + resp.msg)
}
})
FAQs
Easily itegrate your forms with Mailchimp
We found that mailchimp-submitter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.