2014-06-19 49 views
-1

我有jsp頁面,它有用戶名和密碼。如果我們填寫用戶名和密碼並點擊提交按鈕,然後瀏覽器詢問Remember password然後點擊它存儲用戶名和密碼。想要在瀏覽器中存儲用戶名和密碼。我在jsp中使用了autocomplete=off如何在jsp頁面上禁用自動完成

<form name="indexFrm" id="indexFrm" autocomplete="off" method="post"> 

<!DOCTYPE html> 
<html> 
<head> 
<meta http-equiv="Content-Language" content="en-us"> 
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> 
<meta name="GENERATOR" content="Microsoft FrontPage 4.0"> 
<meta name="ProgId" content="FrontPage.Editor.Document"> 
<title>Login</title> 
<script src="http://code.jquery.com/jquery-1.11.min.js"></script> 

<script type="text/javascript"> 




function login(btnName) 
{ 


    if(window.document.indexFrm.userIdTxt.value=="") 
    { 
     alert("Enter User Id"); 
     window.document.indexFrm.userIdTxt.focus(); 
     return false; 
    } 
    if(window.document.indexFrm.pwdTxt.value=="") 
    { 
     alert("Enter Password"); 
     window.document.indexFrm.pwdTxt.focus(); 
     return false; 
    }else{ 
    window.document.indexFrm.action = "../epay/abcd.jsp"; 
    document.indexFrm.method='post'; 
    window.document.indexFrm.submit(); 
    } 

} 



</script> 

</head> 

<body topmargin="0" leftmargin="0" background="../images/background.gif" onLoad = 'window.document.indexFrm.userIdTxt.focus();'> 
<div id="wrapper"> 
    <form name="indexFrm" id="indexFrm" autocomplete="off" method="post"> 
<table width="971" border="0" align="center" cellpadding="0" cellspacing="0"> 
    <tr> 
    <td width="100%" height="15" style="padding-right:4"> 
     <div align="right"> 
     <table border="1" width="10%" cellspacing="0" cellpadding="0" bordercolor="#FFFFFF"> 
      <tr> 
<td width="50%" height="22" bgcolor="#3F9DE5"> 
               <p align="center"><a href="../htmlpages/mainbottom.htm" target="" class="newrightbtn">Home</a> </td> 
      </tr> 
     </table> 
     </div> </td> 
    </tr> 
    <tr> 
    <td width="100%" height="15"></td> 
    </tr> 
    <tr> 
    <td width="100%"> 
     <div align="center"> 
     <center> 
     <table border="1" width="60%" bordercolor="#7CC8FA" cellspacing="0" cellpadding="0"> 
      <tr> 
      <td width="100%"> 
       <table width="100%" border="0" cellpadding="0" cellspacing="1" class="newtexts"> 
       <tr> 
        <td width="100%" bgcolor="#ABDCFC" colspan="2" height="20"> 
        <p align="center" class="newhead">LOGIN</td> 
       </tr> 
       <tr> 
        <td width="100%" bgcolor="#D6EEFE" colspan="2" height="21">&nbsp;</td> 
       </tr> 
       <tr> 
        <td width="42%" bgcolor="#D6EEFE" align="right">User 
           Id&nbsp; </td> 
        <td width="58%" bgcolor="#D6EEFE"><input type="text" name="userIdTxt" size="20" autocomplete="off"></td> 
       </tr> 
       <tr> 
        <td width="42%" bgcolor="#D6EEFE" align="right">Password&nbsp; 
           </td> 
        <td width="58%" bgcolor="#D6EEFE"><input type=password name="pwdTxt" id="pwdTxt" size="20" autocomplete="off"></td> 
       </tr> 

       <td width="100%" colspan="2"><input name="stdSubBtn" type="button" class="newtexts" style="font-family: MS Sans Serif; font-size: 8pt; font-weight: bold" onClick = 'login(this.name);' ></td> 




</table> 
<input type="hidden" name="frmName" value="indexFrm"> 
</form> 
</div> 
</body> 
</html> 
+0

autocomplete =「off」should work,see here - http://stackoverflow.com/questions/468288/input-type-password-dont-let-browser-remember-the-password – Ankit

+0

@ Ankit已經寫了代碼,但它沒有工作 –

+0

它不適用於任何瀏覽器或任何特定的瀏覽器? – Ankit

回答

1

自動完成的作品上HTML5.0,我認爲你正在使用下面的是,只是你的DOCTYPE標記改爲

<!DOCTYPE html> 

然後嘗試。

+0

我沒有使用<!DOCTYPE html>在jsp頁面 –

+1

中插入它在標籤之前。 –

+0

<!DOCTYPE html PUBLIC「 - // W3C // DTD XHTML 1.0 Strict // EN」「http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd」>這是正確的或錯誤的 –