Results 1 to 5 of 5

Thread: [RESOLVED] Javascript: Escape Apostrophe

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Resolved [RESOLVED] Javascript: Escape Apostrophe

    Hi,

    I would think that this has been asked a thousand times, but I couldn't find a simple way to do this. If my javascript string has an apostrophe (or multiple apostrophes), how do I escape it (them)? I'm doing a SQL lookup based on the string and names like O'Reilly cause my app to choke!

    Thanks,
    OneSource

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Javascript: Escape Apostrophe

    Use \'

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Question mendhak ...

    Yea, I know how to escape the character, but I want a function to search the string, locate the apostrophes and return a string with them properly escaped ... In other words, a replace function ....

  4. #4
    Fanatic Member
    Join Date
    Jan 2005
    Location
    In front of this pc.
    Posts
    580

    Re: Javascript: Escape Apostrophe

    Maybe you could split the string and then rebuild it with escaped apostrophes? I havn't done much JS in awhile but when I do and I run into a problem I turn to javascript.internet.com looking for source code...
    What bug? That's not a bug. It's an undocumented feature!

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Thumbs up anotherVBNewbie ...

    thanks. I was able to figure it out using the escape function in my *.js file and using the replace function in my VB.Net webservice to replace single quotes with double quotes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width