I am showing some French line through javascript alert function
and the French line looks like:
S'il vous plaît accepter les termes et conditions avant de procéder
And alert look like in page source:
alert('S'il vous plaît entrer une adresse email valide!');
Firebug is showing an error message like:
SyntaxError: missing ) after argument list
I try to escape the French line like:
alert('S\\'il vous plaît entrer une adresse email valide!');
alert('S\\\'il vous plaît entrer une adresse email valide!');
alert('S"'"il vous plaît entrer une adresse email valide!');
All guidelines were followed, but nothing works. So how do I fix it?
Try -
alert("S'il vous plaît entrer une adresse email valide!");
This is probably the simplest approach. Whenever you need to pass a single quote in a string, wrap it inside a double quote, and vice versa.
If you have a mix of single and double quote in a string, then wrap it inside either single quotes or double quotes, and escape the corresponding ones in the string using a single backslash -
alert("So she said, \"Hey!, how are you?\". I said, 'I am fine, thanks'.")
A single backslash.
alert('S\'il vous plaît entrer une adresse email valide!')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With