General discussion

Locked

Special characters in alert messages

By lakshmi ·
The message in the alert should have an apostrophe. How should i do that?.

For example:
The message is
alert("Date should be greater than tomorrow's date");

actually the message is sent from the script function of a jsp to the function in .js file where the .js file is used in the jsp using src='filename.js'.

This conversation is currently closed to new comments.

10 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Special characters in alert messages

by lakshmi In reply to Special characters in ale ...

If i give a back slash before the apostrophe it is working. but that back slash is part of the alert message when viewed in netscape.

i want the message as it is both in internet explorer and netscape navigator

Collapse -

Special characters in alert messages

by nise_k In reply to Special characters in ale ...

Hi Rashmi,

There is no problem if a single quotes happens to be inside double quotes or vice-versa in JavaScript.

You can go-ahead with your above code and it will work in both IE and Netscape.

Nise

Collapse -

Special characters in alert messages

by lakshmi In reply to Special characters in ale ...

Thanks for ur reply nise.
We do not have problems in having a single quotes within double quotes in java script. But the real problem lies when
the message with single quotes is sent from the script function of a jsp to the function in .js file where the .js file is used in the jsp using src='filename.js'. Look into the comment which i have given which is the major part accounting for problems. Thank you.

Collapse -

Special characters in alert messages

by MadestroITSolutions In reply to Special characters in ale ...

What you are describing is pretty weird. I do stuff like that all the time, and never have that problem. In order to help you, please provide the actual code calling the function, and the code of the function itself. If you dont want to post it here, send it to my e-mail address at: webmaster@KingsDistributors.com

Good Luck!

Collapse -

Special characters in alert messages

by lakshmi In reply to Special characters in ale ...

The question was auto-closed by TechRepublic

Collapse -

Special characters in alert messages

by nise_k In reply to Special characters in ale ...

Hey!

You have messed-up something else. Normally we all use the same strategy of having our common javascript functions (including alerts with quotes) in a common .js, and include this .js inside our .jsp.

So, pls chk it again.

Nise

Collapse -

Special characters in alert messages

by lakshmi In reply to Special characters in ale ...

The question was auto-closed by TechRepublic

Collapse -

Special characters in alert messages

by parkin_thom In reply to Special characters in ale ...

Try using the UNESCAPE function or split your text into two individual strings and then concatenate them when you pass them on to the function that calls the ALERT.

THOM

Collapse -

Special characters in alert messages

by lakshmi In reply to Special characters in ale ...

The question was auto-closed by TechRepublic

Collapse -

Special characters in alert messages

by lakshmi In reply to Special characters in ale ...

This question was auto closed due to inactivity

Back to Web Development Forum
10 total posts (Page 1 of 1)  

Software Forums