html - 是否可以将 html 表单元素包装在多个表单标签中?

标签 html forms html-table tablelayout

<form> 包裹表单的每个元素是否错误? HTML 页面中的标签?很好奇为什么会出错:

基本上我必须介绍两种形式(form1form2),有些元素与第一种相关,而另一些与第二种相关。布局必须完全基于表格,因为两种形式的元素都是整页都是我写的(根据 http://validator.w3.org/check,代码有效):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
 <html>
<head>
   <title>Title of the document</title>
 </head>

 <body>
<table border="1">
    <tr>
        <td>
            <form name="form1" method="POST" action="via.php">
            Enter the first form text here!:    <input type="text" name="first"/>
            </form>
        </td>
        <td rowspan="2">
            <form name="form2" method="POST" action="via.php">
                Enter the second form text here!:<input type="text" name="second"/>
            </form>

            <form name="form1" method="POST" action="via.php">
            Enter the first form text here!:<input type="text" name="first"/>
            </form>
        </td>
  </tr>
  <tr>
        <td>
        <form name="form1" method="POST" action="via.php">
            <input type="submit" name="form1submit" value="submit1"/>
        </form>
        <form name="form12" method="POST" action="via.php">
            <input type="submit" name="form2submit" value="submit2"/>
        </form>
        </td>


  </tr>
</table>

最佳答案

根据the specification,不允许嵌套形式:

Flow content, but with no form element descendants.

w3 validator 中给出这个输入:

<!DOCTYPE html><html><head><title>tit</title></head><body>
<form action="x">
    <form action="x">
        <input type="submit" value="x"> <!-- Submitting.. Which form...?-->
    </form>
</form>    
</body></html>

w3 验证器说:

Saw a form start tag, but there was already an active form element. Nested forms are not allowed. Ignoring the tag.

关于html - 是否可以将 html 表单元素包装在多个表单标签中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9433264/

相关文章:

javascript - 设置自定义有效性 "Empty"

jquery - 使用 JQuery 在 TR 中查找带有文本的第一个 TD

javascript - 保持滚动到底部

javascript - 将 HTML 表单架构保存到 JSON

javascript - Draggable 不是拖动

php - 修改 Drupal 表单字段 - 数组中的 [#weight] 不被尊重?

html:为什么 height 会因 doctype 而失败?

html - 文本溢出: ellipsis not working on th element

php - 从具有不同大小图像的 css 图像 Sprite 中检索图像

html - CSS Sprite - 缩放时显示另一幅图像的一部分