Re: Javascript form validation - comments please
On Sat, 6 Dec 2003 02:09:51 -0000, "Richard Cornford"
<Richard@litote s.demon.co.uk> wrote:
[color=blue]
>"Stephen Poley" <sbpoley@xs4all .nl> wrote in message
>news:8aq1tv8pi gnda65op83sl7ec 8bnucev9e1@4ax. com...
>
>|if (!elem.firstChi ld && !elem.innerHTML )
>
>I forgot to mention that the innerHTML test may not be the best as empty
>strings type-convert to boolean false, so - !elem.innerHTML - will be
>true if the innerHTML string exists but is empty.[/color]
I don't like innerHTML for a different reason... that is it could be
read-only or whatever, so if you're going to test to see if changing
innerHTML works you can do it with
foo.innerHTML=' <b>Chickens</b>'
if (foo.childNodes etc. or whatever non innerHTML methods you prefer
to test the existence of elements.
Jim.
--
comp.lang.javas cript FAQ - http://jibbering.com/faq/
On Sat, 6 Dec 2003 02:09:51 -0000, "Richard Cornford"
<Richard@litote s.demon.co.uk> wrote:
[color=blue]
>"Stephen Poley" <sbpoley@xs4all .nl> wrote in message
>news:8aq1tv8pi gnda65op83sl7ec 8bnucev9e1@4ax. com...
>
>|if (!elem.firstChi ld && !elem.innerHTML )
>
>I forgot to mention that the innerHTML test may not be the best as empty
>strings type-convert to boolean false, so - !elem.innerHTML - will be
>true if the innerHTML string exists but is empty.[/color]
I don't like innerHTML for a different reason... that is it could be
read-only or whatever, so if you're going to test to see if changing
innerHTML works you can do it with
foo.innerHTML=' <b>Chickens</b>'
if (foo.childNodes etc. or whatever non innerHTML methods you prefer
to test the existence of elements.
Jim.
--
comp.lang.javas cript FAQ - http://jibbering.com/faq/
Comment