Attaching forms
Any HTML <form> element can be processed for sending to the Send2CRM service.
Automatic processing
On page load, Send2CRM will automatically check the document for forms that are to be automatically processed using the formSelector setting (by default using CSS class, i.e. <form class="send2crm-form">
).
When these forms are submitted Send2CRM will send all submission data to the service. If the result is successful then the form submit will continue as normal, otherwise an error will be displayed.
Select form programmatically
You can set a form to be submitted via the Send2CRM service directly:
let form = document.querySelector('form#myform');
send2crm.forms.processForm(form);
If the element passed is not a <form> or has already been processed, it will be ignored.
Sending programmatically
A form submission may be triggered by a custom event or in your own submit handler:
let form = document.querySelector('form#myform');
form.addEventListener('submit', (evt) => {
send2crm.forms.sendToService(form);
});