Results 1 to 4 of 4

Thread: Error message

  1. #1
    Join Date
    Jun 2012

    Error message

    When I check the javascript code below on W3 I get this error and I need the < in my code. Any suggestions?

    Line 48, Column 18: StartTag: invalid element name for (var i =0; i < document.forms[0].tasks.length; ++i) {

    Line 52, Column 18: StartTag: invalid element name for (var j =0; j < document.forms[0].tasks.length; ++j) {

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    <html xmlns="http://www.w3.org/1999/xhtml">
    <meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><!-- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> -->
    <title>To Do List</title>

    <script type="text/javascript">
    /* <![CDATA[ */
    /* ]]> */
    function addTask() {
    if (document.forms[0].newtask.value == "")
    window.alert("You must enter a value
    in the New Task fi eld.");
    else {
    if (document.forms[0].tasks
    .options[0].value == "tasks")
    = null;
    var newTask = new Option();
    newTask.value = document.forms[0]
    newTask.text = document.forms[0]
    var numTasks = document.forms[0].tasks
    = newTask;
    document.forms[0].newtask.value = "";

    function deleteTask() {
    var selectedTask = 0;
    var taskSelected = false;
    while (selectedTask < document.forms[0].tasks.length) {
    if (document.forms[0].tasks.options[selectedTask].selected== true) {
    taskSelected = true;
    if (taskSelected == true)
    .options[selectedTask] = null;
    window.alert("You must select a task in
    the list.");
    function ascendingSort() {
    var newTasks = new Array();
    for (var i =0; i < document.forms[0].tasks.length; ++i) {
    newTasks[i] = document.forms[0].tasks.options[i].value;
    for (var j =0; j < document.forms[0].tasks.length; ++j) {
    document.forms[0].tasks.options[j].value = newTasks[j];
    document.forms[0].tasks.options[j].text= newTasks[j];

    <style type="text/css">
    select.c2 {width: 500px}
    input.c1 {width: 150px}
    <h1>To Do List</h1>
    <form action="">
    <p>New Task <input type="text" size="68" name="newtask" /></p>
    <p><input type="button" value="Add Task" onclick="addTask()" class="c1" /> <input type="button" value="Delete Selected Task" onclick="deleteTask()" class="c1" /><br />
    <input type="button" value="Ascending Sort" onclick="ascendingSort()" class="c1" /></p>
    <p><select name="tasks" size="10" class="c2">
    <option value="tasks">Tasks</option>

  2. #2
    Join Date
    May 2006
    Somewhere behind your screen
    1 fix wrong linebreaks
    2 count brackets carefully
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Jun 2012
    Ok, I can fix those items, so does that have a bearing on the fact that the validator is stating that the < is wrong? Thank you for your response that was very helpful.

  4. #4
    Join Date
    May 2006
    Somewhere behind your screen
    another validator shows another error - they are programs and they can't think. the best validator is you <wink>
    Last edited by Padonak; 06-09-2012 at 11:21 AM. Reason: typo
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles