Background mktoForm Submission code — where is my error?
Hi There,
I hope someone can help with this. I'm using the code below, to pass the values from our custom HTML form into Marketo, it works fine for most cases. However, I do see sometimes the form creates an empty lead and some leads don't show up in our Marketo instance. Can someone please advise If I am missing something or how to resolve that issue?
Thanks,
<script>
function SubmitForm(event) {
var form = MktoForms2.allForms()[0];
var fEmail = $('#f_email').val();
var fName = $('#f_name').val();
var fLast = $('#l_name').val();
var fCompany = $('#company').val();
var fPlatform = $('#platform').val();
if( (fEmail != "") && (fName != "") && (fCompany != "") && (fLast != "") && (fPlatform != "")){
form.addHiddenFields({
"Email": fEmail,
"FirstName": fName,
"LastName": fLast,
"Company": fCompany,
"Platform_c": fPlatform
});
form.submit();
}
};
</script>