I have developed the javascript email form, which was discussed here:
HTML Assigning the checkbox to the form action already defined
and everything works fine, also with jQuery elements.
The problem unfortunately lies in the textarea
, where the text input seems to be limited for no reason.
According to the word counter here:
https://textool.io/character-counter/
I can work only with 220 characters. If I exceed this limit, the mailto:
fails.
When I put i.e. one sentence, everything is alright. The problem emerges when I cross some unknown limit of characters. Then the email is not populated.
The full code is here:
https://jsfiddle.net/pq63e4yr/
and the situation depicted here:
I have "discovered" it by using the lorem ipsum text from here:
and now I am trying to find where the problem might be. I saw, that MS Edge has the similar problem
FormData constructor loses textarea value in Edge
but it looks like the Chrome too...
The sample of code (apart from the link above) looks as this:
document.getElementById("cfsubmit").addEventListener("click", function() {
var check = document.getElementById("cfemail");
var formEl = document.forms.cityfibre_form;
var formData = new FormData(formEl);
var jobAddress = formData.get('address');
var jobPostcode = formData.get('postcode');
var surveyorName = formData.get('surveyor');
var feedback = formData.get('feedback');
var subject = jobAddress + ", " + jobPostcode + " - site survey submission from " + surveyorName;
var body = 'SURVEYOR: ' + surveyorName + '\n' +
'ADDRESS: ' + jobAddress + ' ; POSTCODE: ' + jobPostcode + '\n' +
'FEEDBACK: ' + feedback;
var mailTo = "mailto:mk@gmail.com?subject=" + encodeURI(subject) + "&body=" + encodeURI(body);
if (check.checked == true) { // If checked then fire
let link = document.createElement("a");
link.href = mailTo;
link.click();
link.remove();
}
mainForm.submit();
});
<figure class="feedback">
<label class="feedtitle" for="Message">Leave
feedback</label>
<textarea id="opfeedback" name="feedback"></textarea>
<br>
<div class="emailreceipt">
<input type="checkbox" id="cfemail" name="email">
<label class="checking" for="cfemail">Send me an email
receipt of my responses</label>
</div>
</figure>
and I have no idea what's going on here. Is the formData.get
attribute limited with characters?
The similar question:
Getting around mailto / href / url character limit
says about the 2083 characters limit, since according to this counter: https://textool.io/character-counter/
I can work only for 220 characters. I use the Chrome browser.
Is there some reason behind it?