I have a field called [EMAIL="field@code1"]field@code1[/EMAIL] in a form in a XSL page.
i want to use java script to do validation.
the javascript errors if there is a @ in it.
1. is there any way of putitng an @ in javascript
2. is there any other way i can referance the field.

Recommended Answers

All 3 Replies

Java != JavaScript.

Please request to have your thread moved to the JavaScript forum.

This IS the JavaScript forum.

YOu may have to put it in a string, and then use the string as part of an address.

I'm not familiar with XLS. What does the @ represent?

You may also have to have the javascript external, rather than embedded.

Post some code, and the error message you're experiencing. It's a bit difficult to understand what you're doing/where the problem might be. The result of the XSLT transform and the relevant javascript is the part I'd consider to be important to look at, given that you say the problem is with the javascript.

it's not normal to use special characters (i.e. @) in 'names' of elements or 'ids'. I don't know if it's 'forbidden' by spec; but it would make certain things (i.e. CSS and javascript document/etc collections) act wierd, perhaps. If that's what you mean; why do you have, or need, to have @ in the name of an element?

If you do actually NEED one in a name or id, use it as an id on the element.

<input id="field@code1"/>

and use the document.getElementById() method with the ID as parameter, as apposed to using document.forms[X].name, or whatever other collecion-based method you may be using.

var myField = document.getElementById("field@code1");

Code like this though, will certainly not work:

var myField = document.myform.field@code1;

Again, try and get the '@' out of the field id/name. A little investigation into permitted values in W3C XHTML for attribute of type 'id' says the pattern should be:

[A-Za-z][A-Za-z0-9:_.-]*
//That is, one upper/lowercase alphabetic character followed by any number of alphanumeric characters, and/or (:_.-) characters

See:
http://www.w3.org/TR/xhtml1/#C_8
http://www.w3.org/TR/html4/types.html#h-6.2

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.