| Author |
'&' missing while displaying Textbox values in JSP/jquery/javascript
|
S Nikam
Greenhorn
Joined: Dec 28, 2010
Posts: 11
|
|
Hi,
I am getting some weired behaviour for below case.
Please help if anybody knows this issue.
I have jsp with texbox,I click next it will confirm the inputs on cofiramtion page and then submit.
In jsp when I enter any string with '&',its behaviour is as below.
abc & def --->abc & def
abc & def & -->abc & def
abc&def&ghi--> abc&def
abc&def&ghi & test-->abc&def&ghi & test
Means when I enter string with '&' without space the string/character after last '&' is
missing on the confirmation page.I am using jquery/javascript to display information on confirmation page.
Please help ..
Thanks!!
ssn
|
 |
S Nikam
Greenhorn
Joined: Dec 28, 2010
Posts: 11
|
|
Got the solution for this
var name1 = document.getElementById(name).value;
name1 = name1.replace(/\&/g,'&');;
element1.innerHTML =name1
Thanks
ssn
|
 |
Stefan Evans
Bartender
Joined: Jul 06, 2005
Posts: 1004
|
|
You do realise that & is a special character in HTML?
It should be encoded as & in any html.
The JSTL <c:out> tag will do that for you automagically.
& is also a special character in urls (used to seperate parameters). however if you are submitting a form, then that should be escaped automatically for you as well.
If you are building up the url string yourself, make sure you URLEncode any parameter values, which will escape the & characters.
Also note that to write & on this forum you write it as &amp;
|
 |
 |
|
|
subject: '&' missing while displaying Textbox values in JSP/jquery/javascript
|
|
|