Html 表单在 Internet Explorer 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2005015/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Form not working in Internet Explorer
提问by nicky
This form code is working in Mozilla and Chrome, but in Internet Explorer it is not working.
此表单代码在 Mozilla 和 Chrome 中有效,但在 Internet Explorer 中无效。
<form method="post" action="logincheck.php" >
<span class="meta">
<table>
</span>
<tr>
<td>
<span class="meta">
<label >Username </label>
</span>
<label>
</td>
<td> <input name="username" type="text" />
</label>
</form>
</td>
</tr>
<tr>
<td> <label ><span class="meta">Password</td>
<td>
<input name="password" type="password" />
</span>
</label>
</td>
</tr>
<tr>
<td>
<span class="meta">
</span>
<label>
<input type="submit" name="Submit" value="Submit" class="submit"/>
</label>
</td>
</tr>
</table>
</form>
回答by Olly Hodgson
You have a number of HTML errors, most important being an extra </form>
tag shortly after the first <input>
. That means the second input
and the submit
button are outside the form, so it won't work. Firefox and Chrome are being a bit more forgiving here it seems.
您有许多 HTML 错误,最重要的是</form>
在第一个<input>
. 这意味着第二个input
和submit
按钮在表单之外,所以它不起作用。Firefox 和 Chrome 在这里似乎更宽容一些。
Fix your HTML and the form should work fine.
修复您的 HTML,表单应该可以正常工作。
回答by Quentin
回答by Burntime
<form method="post" action="logincheck.php">
<label for="username">Username</label>
<input name="username" type="text" />
<label for="password">Password</label>
<input name="password" type="password" />
<input type="submit" name="Submit" value="Submit" class="submit" />
</form>
The correct code for this form must look like this.
此表单的正确代码必须如下所示。
- You do not need the table, you can style the form with easily with CSS over selecting the label & input fields
- 您不需要表格,您可以使用 CSS 轻松设置表单样式,而不是选择标签和输入字段
回答by Sietse
<span class="meta">
<table>
</span>
<span class="meta">
<table>
</span>
The nesting is wrong. In fact, there's a lot more wrong. Try googling what <label>
does exactly, and what <span>
does and when you want to use it. You probably want something like this:
嵌套是错误的。其实错的还很多。尝试在谷歌上搜索究竟<label>
是什么,什么<span>
是你想要使用它的时间。你可能想要这样的东西:
<form method="post" action="logincheck.php" >
<table>
<tr>
<td><label class="meta">Username </label></td>
<td><input name="username" type="text" /></td>
</tr>
<tr>
<td><label class="meta">Password</td>
<td><input name="password" type="password" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="Submit" value="Submit" class="submit"></td>
</tr>
</table>
</form>
回答by enguerran
One first error is:
第一个错误是:
<span class="meta">
<table>
</span>
But you have many errors.
但是你有很多错误。
Open and close tags as you will do with parenthesis. No horse riding. HTML and now XHTML need you to be a little bit more conscientious.
打开和关闭标签,就像使用括号一样。没有骑马。HTML 和现在的 XHTML 需要您更加认真。
usefull tool:
有用的工具:
回答by YOU
Here is a version without span tags, label and extra </form>
in the middle of the table before submit button.
这是</form>
提交按钮前表格中间没有跨度标签、标签和额外内容的版本。
I guess, you added those by hands in plain text editors.
我想,您是在纯文本编辑器中手动添加的。
<form method="post" action="logincheck.php">
<table>
<tr>
<td>
Username
</td>
<td>
<input name="username" type="text" />
</td>
</tr>
<tr>
<td>
Password
</td>
<td>
<input name="password" type="password" />
</td>
</tr>
<tr>
<td>
<input type="submit" name="Submit" value="Submit" class="submit" />
</td>
</tr>
</table>
</form>