2011-04-13 70 views
-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> 
+0

即甚至没有相干的代码;你没有关闭你的输入标签,并且你在“onClick”属性中有随机标签,这实际上应该是XHTML中的“onclick”。你也有一个空的类型的输入标签,这也没有意义。 – mc10 2011-04-14 17:37:01

回答

0

那么你的问题是你没有文档类型,HTML,头或身体标记。

0

您的页面无法验证,仅仅是因为您错误地嵌套/关闭标签,并且某些标签对它们没有正确的属性。

+0

注意:不要打扰编辑这个问题,试图使其突出显示。根本问题是缺乏基本的连贯性。 – 2011-04-17 23:28:47

+0

好吧,没关系。 – mc10 2011-04-17 23:38:43

0

首先,您正在讨论xhtml,并添加了xhtml-1.0-strict标签,但您的标题状态为:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

我从来没有见过我的生活<body class="oneColFixCtr">类,被添加到<body>。您可以通过以下方式操作<body>的CSS:body {background: red;}

有1x <div>标签缺失!有1x额外</p>。很多标签没有以/结束。 <form>缺少方法和操作参数!

此外,如果你想100%完美的验证,你不能使用onclick=""。我将jQuery添加到脚本中。

直播例如:http://kopli.pri.ee/stackoverflow/5653786.phpclick here验证)

代码的完整版:

<!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>