Skip to content
Advertisement

Replace colon in javascript before sending the form

I have a text input search field. I’d like to add an escape backslash to any colon entered by the user. This is what I have right now:

JavaScript

It doesn’t seem to work, though: the string sent to the ‘q’ parameter has the colon without the escape character. What am I missing?

Advertisement

Answer

Even when fixing the replacement with the additional backslash, your code still wont work because you also need to change the value of the form field with its new value, as follows “new code”:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement