【发布时间】:2015-01-24 01:37:55
【问题描述】:
问题——似乎我不能将两个表单嵌入到一个表中并验证我的 HTML。例如,W3 Validator 给了我Element <form> not allowed as child of element <tr> in this context. 我看不到解决验证错误的方法。
我想要实现的是:
- 在 html 表“行”中,我可以更改一些输入值,然后使用行末尾的“保存”按钮来保存它们
- 如果我必须删除一行,我可以通过按 Delete 按钮来完成。
- 在 UI 方面,我觉得有两种表单很有意义,每行一个用于保存/删除按钮。
- 我可以有几行,每行都有自己的保存/删除按钮
用户界面示例
数字是输入字段,保存/删除是按钮。
下面是我简化的不符合要求的 HTML:
<!DOCTYPE html>
<html>
<head>
<title>HTML</title>
</head>
<body>
<table>
<tr>
<form>
<td><input type="text" name="row_id" value="1"></td>
<td><input type="text" name="five" value="5"></td>
<td><input type="text" name="three" value="3"></td>
<td><input type="submit" value="Save This Row"></td>
</form>
<td><form>
<input type="text" name="row_id" value="1">
<input type="submit" value="Delete This Row">
</form></td>
</tr>
</table>
</body>
</html>
HTML 的工作令人惊讶,但它不验证。我正在寻找一种既能工作又能验证的解决方案。
【问题讨论】:
标签: html forms html-table html-validation