2012-02-25 66 views
1

我的表格附在下面,我嘗試了很多我在其他論壇找到的東西,但無濟於事。我不能讓瀏覽器提示「保存密碼」。我哪裏錯了。希望有人能幫忙。謝謝。沒有「保存密碼」任何瀏覽器對我的形式提示

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

回答

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應該是u NIQUE
  • 屬性name中尋找密碼和用戶名定義了兩次
  • 屬性autocomplete是默認on
  • 輸入value不是必需的,所以您不必將其與空添加到輸入串
  • 提交按鈕應提交類型的輸入

一些變化只是優化和代碼可以在沒有他們的工作很好,但其他諸如確保唯一ID每個標記都是修正,即使瀏覽器正確顯示錶單,也強烈建議使用它們。

相關問題