using indexof to find a quote

G

Glenn M

how can i use the .indexof function to check if there is a quote in the string.

i can't seem to find the correct syntax for do this without an error occuring
 
L

Lasse Reichstein Nielsen

how can i use the .indexof function to check if there is a quote in
the string.

string.indexOf("'")

Are you using it inside an HTML event handler (onclick etc.)?
In that case, you need something like:

... onclick=" ... string.indexOf('\'') ... "

/L
 
L

Lasse Reichstein Nielsen

Sorry, I meant string.indexOf ('"')

Inside a "-delimited intrinsic event, the " in '"' would still be used
to match the beginning ". The HTML parser doesn't know that the " is
inside single quotes in the Javascript, because it only looks at the
HTML.

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,685
Members
48,796
Latest member
Greg L.

Latest Threads

Top