开发者

Form not working in Internet Explorer

This form code is working in Mozilla and Chrome, but in Internet Explorer it is not working.

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


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.

Fix your HTML and the form should work fine.


You have errors that automated QA tools can detect


<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


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

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


Here is a version without span tags, label and extra </form> in the middle of the table before submit button.

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>


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.

usefull tool:

  • http://giminik.developpez.com/xhtml/
  • http://validator.w3.org/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜