Special characters on input come in as %nn Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Special characters on input come in as %nn without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I have an HTML FORM requesting the name of a movie to search for, and a JavaScript function which takes that name passed as a query parameter (after a ?) on a reinvocation of the page URL and compares it against a database (read with AJAX). The problem is that special characters are being translated on input to %nn, so they don’t match the names in the database. For example, when I read the user input of “airplane!” with “title = window.location.search” I receive “airplane%21”. How can I defeat or correct this behavior, or am I going to have to translate every %nn in my JavaScript routine? Thank you. (Page reference: https://acb.org/adp/findavideo.html)

Arggh! Not 2 seconds after I posted this, someone sent me an answer offline: “title = decodeURIComponent(title)” does the trick. Hope this helps someone else.


You can try decode the value before use it, for example:

decodeURIComponent('%21'); // "!"
We are here to answer your question about Special characters on input come in as %nn - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji