-2
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>The Magic Genie</title>
<link href="java-game.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="java-game.js"></script>
</head>

<body class="oneColFixCtr">

<div id="container">
  <div id="mainContent">
    <h1>Ask Your Magic Genie </h1>

<form>
Your question: <input type="text" name="question" size="40">
<input type="button" name="ask" value="Ask the Genie" onClick="if (this.form.question.value!='') this.form.answer.value = genie();">
<br />
<br />
Your magic genie says:  <input type="text" name="answer" size="50">
</form></p>


</div>
</body>
</html>
TylerH
  • 20,799
  • 66
  • 75
  • 101
stuff123
  • 11
  • 1
  • That isn't even coherent code; you didn't close your input tag, and you have random tags within an "onClick" attribute, which should actually be "onclick" in XHTML. You also have an input tag with an empty type, which also makes no sense. – Kevin Ji Apr 14 '11 at 17:37

3 Answers3

0

Well your problem is you have no doctype, html, head or body tag.

Ozzy
  • 10,285
  • 26
  • 94
  • 138
0

Your page will not validate, simply because you are incorrectly nesting/closing tags, and some tags do not have correct attributes to them.

Kevin Ji
  • 10,479
  • 4
  • 40
  • 63
  • Note: Don't bother editing this question to try to make it highlight. The fundamental problem is the lack of basic coherence. – Donal Fellows Apr 17 '11 at 23:28
0

First of ALL things you are talking about xhtml and added xhtml-1.0-strict tag, but your heading states: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">.

I've never in my life seen <body class="oneColFixCtr"> class, being added to <body>. You can manipulate <body> in CSS by: body {background: red;}.

There were 1x <div> tags missing! There was 1x extra </p>. Lots of tags were not ended with /. <form> was missing method and action parameter!

Also, if you want 100% perfect validation, you cant use onclick="". I added jQuery to your script.

Live example: http://kopli.pri.ee/stackoverflow/5653786.php (click here to validate)

Full version of the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>I am trying to validate this form page xhtml and it will not validate - Kalle H. Väravas</title>
    <link href="java-game.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
    <script type="text/javascript" src="java-game.js"></script>
</head>
<body>
    <div id="container">
        <div id="mainContent">
            <h1>Ask Your Magic Genie </h1>
            <form method="post" action="">
                Your question: <input type="text" name="question" size="40" />
                <input type="button" name="ask" value="Ask the Genie" /><br />
                <br />
                Your magic genie says:  <input type="text" name="answer" size="50" />
            </form>
        </div>
    </div>
    <script type="text/javascript">
        $('input[name=ask]').click(function () {
            if ($(this).form.question.value!='') {
                $(this).form.answer.value = genie();
            }
        });
    </script>
</body>
</html>
Kalle H. Väravas
  • 3,579
  • 4
  • 30
  • 47