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

Help required - Problem with illegal characters

P: n/a

Hi - I am having problems witrh the code below (obviously) coming up
with illegal character for various characters within the field name
which is:

S_Gift Finder1_0
I have tried various ways of escaping the characters but to no avail.

I am unable to change the name of the field as it it comes from an
external off-the-shelf package.

See below for full javascript funtion.

Any help would be appreciated.

// define function to check that gift type and /or price range has
been chosen

function valgiftprice() {
if (document.forms) {
if (document.forms["giftfinder"].S_Gift Finder1_0.value == ""
&& document.forms["giftfinder"].PR.value == "-1") {
alert("Please choose a Gift Type or Price Range.");
document.forms["giftfinder"].S_Gift Finder1_0.focus();
return false;
}
return true;
}
}
Jan 25 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
VK

skinnybloke wrote:
Hi - I am having problems witrh the code below (obviously) coming up
with illegal character for various characters within the field name
which is:

S_Gift Finder1_0


JavaScript char sequences must be represented as u-escaped Unicode hex
pairs:
\uFFFF

So say _ would become \u005F : "S\u005FGift Finder\u005F0"
(see <http://www.unicode.org/charts/>)

But \u005F is simply underscore, and you don't have to escape it. It is
much simplier to type it: "S_Gift Finder_0".
So either you wanted some other character, or your problem is in some
other place and you want to solve it (no hope) by escaping chars.

Jan 25 '06 #2

P: n/a
_ is underscore symbol.

Try this:
document.forms["giftfinder"].all["S_Gift Finder1_0"].value

Jan 25 '06 #3

P: n/a
VK

marss wrote:
_ is underscore symbol.

Try this:
document.forms["giftfinder"].all["S_Gift Finder1_0"].value


Underscore is a valid character for identifier (unlike .all method btw
;-)

What breaks the code is the *space* which is not allowed in identifiers
in any form (escaped or not).

As it was stated that the name cannot be changed, then the only way is:
document.forms["giftfinder"].elements["S_Gift Finder1_0"].value

P.S. And I'm really sorry this "standard escape" is allowed. But it's
IMHO.

Jan 25 '06 #4

P: n/a
On 25 Jan 2006 06:11:12 -0800, "VK" <sc**********@yahoo.com> wrote:

Thanks for the replies guys. I eventuallty found a way to remove the
space from the name within the package.

I was then able to use S_GiftFinder1_0 as the field name as suggested.
What breaks the code is the *space* which is not allowed in identifiers
in any form (escaped or not).


Jan 25 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.