problem with ";" and "&" in form inputs in sendGrid

Hi
I made a form with sendGrid with following " Wix support codes"

I did not change the codes.
However, when the user type “;” or “&” or presses enter to make a new line in any text input, the generated email is cut after the first typed character until the end. But, the text is saved in the database correctly.

what should i do?
Thanks,
Ali

Hi Ali,
Depending on how are you sending your HTML code through SendGrid, sometimes you need to ESCAPE certain characters before they can be sent out.

For example:
Ampersand (&) must be converted to “&”
Semicolon (:wink: must be converted to “;”

Here is the complete list of Entities: CLICK HERE
Look also for ENCODING HTML ENTITIES in JavaScript

Good Luck
-Luigi

2 Likes

Thank you.
I tried a lot but did not figure out how to escape characters in text boxes.

Hi Ali. Not sure if you ever got this figured out, but I just did and thought I would share with you and anyone else who stumbles on this post looking for the answer (like I did!).

This is actually VERY simple, and I have confirmed that the code works with my SendGrid emails. SendGrid no longer cuts off the “&” and all text after it.

function sendEmails() {
	const carvedText = escape($w("#textBox1").value);
	const addComments = escape($w("#textBox3").value);
	const subject1 = `We have received your custom quote request, ${$w("#input1").value}`;
	
	 const body1 = `Hi, ${$w("#input1").value}! Thank you so much for submitting your 
	custom quote request! We have provided a summary of the details of your request 
	below.      
	\rCUSTOM QUOTE DETAILS:   
	\rBASICS     
	\rText to Carve: ${carvedText}     
	\rADDITIONAL COMMENTS: ${addComments}   
	\r*This email has been sent from an unmonitored mailbox. Please do not "reply" to this email.    
	\rThanks!`; 

I’ve “bolded” the lines that you need in the above code. If the code doesn’t seem quite complete, it’s because I’ve removed parts of it that weren’t relevant to answering your question.

Hope this helps!
Thanks.
Tammy Holliday
www.HollidayWoodworks.com

1 Like

More on escape characters…

http://net-informations.com/js/iq/escape.htm

Hi Tammy,

I’ve been reading the thread above, i notice that:
const carvedText = escape($w(“#textBox1”).value);
corresponds with \rText to Carve: ${carvedText}

further down the code, did you find that you needed to enter this for each field where an escape character could be entered?

I’m trying to resolve the issue on an application form. So i’m just wondering if i will need to complete the action for each text box? Or whether i can configure the code to apply to the whole form.

Thanks Hannah