By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,708 Members | 1,502 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,708 IT Pros & Developers. It's quick & easy.

using indexof to find a quote

P: n/a
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
Jul 23 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
gl**********@bt.com (Glenn M) writes:
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2

P: n/a
sorry i meant a double quote

whould it just be this

string.indexOf("\"")
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<65**********@hotpop.com>...
gl**********@bt.com (Glenn M) writes:
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

Jul 23 '05 #3

P: n/a
gl**********@bt.com (Glenn M) writes:
sorry i meant a double quote

whould it just be this

string.indexOf("\"")


Try it! :)

/L 'and don't top post!'
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #4

P: n/a
gl**********@bt.com (Glenn M) wrote in message news:<32**************************@posting.google. com>...
sorry i meant a double quote

whould it just be this

string.indexOf("\"")
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<65**********@hotpop.com>...
gl**********@bt.com (Glenn M) writes:
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


How about just string.indexOf("'")
Jul 23 '05 #5

P: n/a
gl**********@bt.com (Glenn M) wrote in message news:<32**************************@posting.google. com>...
sorry i meant a double quote

whould it just be this

string.indexOf("\"")
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<65**********@hotpop.com>...
gl**********@bt.com (Glenn M) writes:
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


Sorry, I meant string.indexOf ('"')
Jul 23 '05 #6

P: n/a
br*************@glic.com (bruce) writes:
> ... onclick=" ... string.indexOf('\'') ... "
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.