Re: Escaping ()
by "Steve Mount" <steve(at)saltyrain.com>
|
Date: |
Thu, 27 Jun 2002 19:40:04 -0400 |
To: |
<jkeilholz(at)triad.rr.com>, <hwg-techniques(at)hwg.org> |
References: |
atp |
|
todo: View
Thread,
Original
|
|
According to the JS spec, valid variable names (and the name of a form
element is just a variable name to JS) can contain only A-Z, a-z, 0-9, _ and
$ (no numbers as the first character in a name). The ( and the ) characters
are not legal, and will probably never work the way you want them to.
You could refer to the form element with its document.forms[].elements[]
value, but I would do that only if absolutely necessary - this format (while
universal) is very easy to break.
-------------------------------------------------------------
Steve Mount, Software Engineer steve(at)saltyrain.com
Home Site http://www.saltyrain.com
US Constitution Online http://www.usconstitution.net
----- Original Message -----
From: "jkeilholz" <jkeilholz(at)triad.rr.com>
To: <hwg-techniques(at)hwg.org>
Sent: Thursday, June 27, 2002 4:47 PM
Subject: Escaping ()
> Hey All!
>
> I'm trying to check a variable in a form but I am having a slight
difficulty
> with the name of it. Due to the cgi script that I am using I need to have
> the name of the form equal to "$char(1)_understand" so that it requires a
> value for the field. However, I am also trying to verify the form through
> Javascript before I pass the form to the script so that if they don't give
> the correct answer the user will be alerted to respond. In doing so I am
> writing a simple little verifier such as:
>
> accepted = form1.$char(1)_understand.value;
> if (accepted == "agree"){
> return true;
> }
>
> BUT>>>> The problem lies in the (). Netscape continuously tells me that
it's
> expecting a ; following that spot but of course that's not what I want to
> do. I'm trying to determine the best approach for the regular expression
but
> there doesn't seem to be anything to escape the line. I've even tried the
> expression /(form1\.\$\char\(1\)_understand\.value)/ but it still doesn't
> work. Any one have any ideas?
>
> Thanks in Advance,
> Joe Keilholz
>
>
> BTW: If you'd like to see the full page, go to
> http://www.news-record.com/store/archives.html
>
>
HWG hwg-techniques mailing list archives,
maintained by Webmasters @ IWA