| Autor | Zpráva | ||
|---|---|---|---|
| dako Profil |
#1 · Zasláno: 23. 4. 2012, 19:06:45
Ahojte mám problém s validáciou JS - stále mi v nasledovnej časti JS vypisuje mnohe chyby
{
hodnota = '<input id="pokus'+info+'" type="text" size="4" onkeyup="pokusik(this.value,'+"'"+info+"',"+cena_fotky+')"/>';
hidden = '<input type="hidden" id="hidden_pokus'+info+'" name="sumy[]" value="" />"';
document.getElementById('info'+info).innerHTML = hodnota + '' + hidden;
}Pre info tu su tie chyby, ktore mi pise: Line 120, Column 32: character "'" is not allowed in the value of attribute "id" hodnota = '<input id="pokus'+info+'" type="text" size="4" onkeyup="pokusik(… ✉ It is possible that you violated the naming convention for this attribute. For example, id and name attributes must begin with a letter, not a digit. Line 120, Column 94: an attribute specification must start with a name or name token …="text" size="4" onkeyup="pokusik(this.value,'+"'"+info+"',"+cena_fotky+')"/>'; ✉ An attribute name (and some attribute values) must start with one of a restricted set of characters. This error usually indicates that you have failed to add a closing quotation mark on a previous attribute value (so the attribute value looks like the start of a new attribute) or have used an attribute that is not defined (usually a typo in a common attribute name). Line 120, Column 94: document type does not allow element "input" here …="text" size="4" onkeyup="pokusik(this.value,'+"'"+info+"',"+cena_fotky+')"/>'; ✉ The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed). One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error). Line 120, Column 95: end tag for "input" omitted, but OMITTAG NO was specified …="text" size="4" onkeyup="pokusik(this.value,'+"'"+info+"',"+cena_fotky+')"/>'; ✉ You may have neglected to close an element, or perhaps you meant to "self-close" an element, that is, ending it with "/>" instead of ">". Line 120, Column 16: start tag was here hodnota = '<input id="pokus'+info+'" type="text" size="4" onkeyup="pokusik(… Line 121, Column 49: character "'" is not allowed in the value of attribute "id" … = '<input type="hidden" id="hidden_pokus'+info+'" name="sumy[]" value="" />"'; ✉ It is possible that you violated the naming convention for this attribute. For example, id and name attributes must begin with a letter, not a digit. Line 121, Column 83: document type does not allow element "input" here … = '<input type="hidden" id="hidden_pokus'+info+'" name="sumy[]" value="" />"'; ✉ The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed). One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error). |
||
| Fisir Profil |
#2 · Zasláno: 23. 4. 2012, 20:45:27
A ten skript funguje? Navíc, v popisu chyby máš vše potřebné.
|
||
| Nox Profil |
#3 · Zasláno: 23. 4. 2012, 20:53:09
No anebo to prostě vyhoď do samostatného souboru a máš to
|
||
| dako Profil |
#4 · Zasláno: 23. 4. 2012, 21:35:57
Skript funguje bez problémov, a do externého súboru som to už skúšal dať ale validator číta komplet cely kod, teda aaj vratane toho skriptu a to bez ohladu na to kde je umiestneny...
|
||
| Davex Profil |
#5 · Zasláno: 23. 4. 2012, 22:20:43
Jaký má smysl kontrolovat JavaScript HTML validátorem? Neměl bys ho před validátorem schovat?
|
||
| weroro Profil |
#6 · Zasláno: 23. 4. 2012, 22:27:15 · Upravil/a: weroro
To čo je v premennej hodnota je nezmysel. Ten reťazec je zle pospájaný v časti kde je funkcia. (Alebo sa v JS nerozlišuje apostrof od úvodzovky?)
hodnota = '<input id="pokus'+info+'" type="text" size="4" onkeyup="pokusik(this.value,'+"'"+info+"',"+cena_fotky+')"/>'; |
||
| Chamurappi Profil |
#7 · Zasláno: 23. 4. 2012, 22:56:28
Reaguji na daka:
Validátor si myslí, že používáš XHTML, a proto obsah elementu <script> vyhodnocuje jako obsah libovolného jiného elementu (nachází v něm další HTML elementy apod.), místo toho, aby ho bral jako skript. Prohlížeče samozřejmě vidí kód jako HTML, jinak by ti ten skript nemohl fungovat. Proč se snažíš dodržovat jiná pravidla, než jaká mají používat prohlížeče?
|
||
| _es Profil |
#8 · Zasláno: 24. 4. 2012, 06:13:30
weroro:
„reťazec je zle pospájaný“ Reťazec je v poriadku, v zvýraznených častiach sú dva reťazce uzavreté v úvodzovkách: jednoznakový reťazec obsahujúci apostrof a dvojznakový reťazec obsahujúci apostrof a čiarku. |
||
| Trejpa Profil |
#9 · Zasláno: 24. 4. 2012, 10:10:12
dako:
V pravém XHTML lze kód skriptu uzavřít do sekvence CDATA, která z něj vytvoří komentář a ten pak validátor nevidí. <script type="text/javascript"> //<![CDATA[ (obsah skriptu) //]]> </script> Ty však používáš HTML se špatnou deklarací, takže to dělat nemusíš, protože to ničemu nepomůže, viz Chamurappi [#7]. |
||
|
Časová prodleva: 1 rok
|
|||