We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


plus character in forms

Medium Priority
Last Modified: 2013-12-25
So, I have this gaming site, and people have a search form where they can search for game titles. Yesterday, I found a bug with this and I'm unsure where the bug is - with the browser or if there is something I can do.

There is a game called "N+", which is its complete title. But, when searching for that using a form that has GET as the method, the resulting URL will be:


That may look right, but "+" in url's are treated as spaces (even though an url encoded space is %20) and as such, that url would send the value "N " as the search string, which of course wouldn't match the games.

Is there anyting one can do to remedy this?
Watch Question

check and convert it to %2B

whole list of url escape codes


How do I check and convert it? I mean - it's sent as a part of the form submittng. So in the recieving end (the form action target) I get "N ". At what point should I "check and convert it"?
before submit the form.

you can use the event onsubmit() to make a javascript to replace all presence of the + sign to %2B. Using something like below
<script type="text/javascript">
var replaceStr = "%2B";
var myOldString = "Hello+world+friend";
var myNewString = myOldString.replace(/\+/g, replaceStr );
document.write("Old string =  " + myOldString); 
document.write("<br />New string = " + myNewString);

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Uhm, so you're saying that the only way to remedy this "bug" is to put a javascript handler on every form (since I'd like to remedy this for all forms, not just the game search form)?

That seems like an awfully awkward way of handling things, especially if the user doesn't have JS turned on. Hmmm.
I dun think it's a bug but just some kind of communication mismatch between client and server. The concern is on why the client browser do not encode it and the server side do not decode it properly.

I am just pointing out one possible way to handle this.
And more, nowadays js is already a essential part of web pages, if js is not enabled many page functions simply don't work. Then do you mean you will avoid all tasks made by javascript? If not then your reply of "especially if the user doesn't have JS turned on." doesnt make sense at all.


No, I didn't mean to complain about your solution, I'm sure it works as described. I just expressed a frustration over having to resort to JS to solve a problem you describe as something between the client and server... :/ I'll award you points soon, unless a betetr solution shows up soon enough :)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.