【问题标题】:how to disable autocomplete on in jsp page如何在jsp页面中禁用自动完成
【发布时间】:2014-08-09 17:34:24
【问题描述】:

我有jsp页面它有用户名和密码。如果我们填写用户名和密码并点击提交按钮然后浏览器询问Remember password然后点击它存储用户名和密码。我不想存储用户名和密码在浏览器中。我在 jsp 中使用了autocomplete=off

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

【问题讨论】:

  • autocomplete="off" 应该可以工作,见这里 - stackoverflow.com/questions/468288/…
  • @Ankit 我已经写了代码但是没有用
  • 它在任何浏览器或任何特定浏览器中都不起作用吗?
  • @Ankit 它在 Firefox 中不起作用

标签: javascript html jsp auditing


【解决方案1】:

自动完成适用于 HTML5.0,我认为您在下面使用,只需将您的 doctype 标签更改为

<!DOCTYPE html>

那就试试吧。

【讨论】:

  • 我没有在jsp页面中使用
  • 在你的 标签之前插入它。
  • ttp://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" rel="nofollow" target="_blank">w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">这是对还是错
  • 只插入 不是完整的东西。
猜你喜欢
  • 2015-01-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-18
  • 2014-08-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多