我的表单没有任何浏览器的“保存密码”提示

时间:2012-02-25 09:17:34

标签: html forms zend-framework

我的表格附在下面,我尝试了很多我在其他论坛找到的东西,但无济于事。我无法让浏览器提示“保存密码”。我哪里错了。希望有人能提供帮助。感谢。

<form id="frmlogin" action="/index" method="post" enctype="application/x-www-form-urlencoded" autocomplete="on">
        <label id="landing_username" class="required" for="username">Username/Email</label>
        <input id="landing_username" name="username" type="text" value="" name="username" />
        <label id="landing_password"  class="required" for="password">Password</label>
        <input id="landing_password"  name="password" type="password" value="" name="password" />
        <submit id="loginbtn" onclick="LoginFun()" type="submit" name="loginbtn">Login</submit>
</form>

1 个答案:

答案 0 :(得分:4)

尝试清理一下HTML,也许有帮助:

<form id="frmlogin" action="/index" method="post">
    <label id="landing_username" class="required" for="username">Username/Email</label>
    <input id="username" name="username" type="text"  />
    <label id="landing_password"  class="required" for="password">Password</label>
    <input id="password" name="password" type="password" />
    <input id="loginbtn" onclick="LoginFun()" type="submit" name="loginbtn" value="Login" />
 </form>
  • 表单属性enctype默认为application/x-www-form-urlencoded,因此您无需指定
  • 标签for属性应包含id,而不是相关输入的name
  • 元素ID应该是唯一的
  • 为密码和用户名
  • 定义属性name两次
  • 属性autocomplete默认为on
  • 输入value不是必需的,因此您无需将其添加到带有空字符串的输入中
  • 提交按钮应为提交类型
  • 的输入

其中一些更改只是优化,代码可以在没有它们的情况下正常工作,但是其他一些(例如确保每个标记的唯一ID)是修复程序,即使浏览器正确显示表单,也强烈建议使用它们。