사용하지 않도록 설정하는 방법을 자동 완성 브라우저에서 텍스트 입력을 선택적으로 코드를 통해?

StackOverflow https://stackoverflow.com/questions/1929486

문제

그것은 선택적으로 사용하지 않도록 설정 자동완성 기능을 사용하여 텍스트 필드에 코드?

나는 발전 내에서 사용자 지정 코드 ASP.Net AJAX 을 검색에 대한 제안서 및 데이터베이스하고 싶지는 브라우저의 제안에 나타나는 경우 사용자가 입력을 시작하면서 textbox.

내가 찾는 것은 솔루션에서 작동하는 가장 현대적인 브라우저(IE7 및 8,Firefox,Safari,Chrome).그것은 좋은 경우 이 문제를 해결에서 Javascript.

도움이 되었습니까?

해결책

보 자동 완성 HTML 특성(양식에 또는 태그 입력).

<form [...] autocomplete="off"> [...] </form>

W3C>자동완성 특성

편집:

요즘에는 의견 웹 브라우저하지 않는 항상 존경을 자동 완성된 태그 정의된 동작입니다.이 아닌 존경될 수 있으로 둘러싸인의 작은 JavaScript 코드 하지만 당신은 당신에 대해 생각하고 싶어 하기 전에 이것을 사용합니다.

첫째,필드를 것이 가득하는 동안 페이지 로딩을 비우면니다.사용자는 것입니다 문제는 왜 필드되었습니다.

둘째,이를 재설정 다른 웹 브라우저 메커니즘처럼,자동완성의 분야에 갈 때 당신은 이전 페이지로 돌아.

jQuery( function()
{
  $("input[autocomplete=off]").val( "" );
} );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<form method="post" action="">
  <div class="form-group">
    <label for="username">Username</label>
    <input type="text" id="username" name="username" value="John" autocomplete="off">
  </div>
  <div class="form-group">
    <label for="password">Password</label>
    <input type="password" id="password" name="password" value="qwerty" autocomplete="off">
  </div>
  <input type="submit" value="Login">
</form>

다른 팁

입력에 넣을 수 있습니다.

<input type="text" name="off" autocomplete="off">

또는 jQuery에서

$(":input").attr("autocomplete","off"); 

이 문제에 대한 두 가지 해결책이 있습니다. Google Chrome v36에서 다음 코드를 테스트했습니다. 최근 버전의 Google Chrome Forces Autofill에 관계없이 Autocomplete=off. 이전 해킹 중 일부는 더 이상 작동하지 않습니다 (34+ 버전)

Solution 1:

아래에 다음 코드를 넣으십시오 <form ..> 꼬리표.

<form id="form1" runat="server" >
<input style="display:none" type="text" name="fakeusernameremembered"/>
<input style="display:none" type="password" name="fakepasswordremembered"/>

...

더 읽으십시오

Solution 2:

$('form[autocomplete="off"] input, input[autocomplete="off"]').each(function () {

                var input = this;
                var name = $(input).attr('name');
                var id = $(input).attr('id');

                $(input).removeAttr('name');
                $(input).removeAttr('id');

                setTimeout(function () {
                    $(input).attr('name', name);
                    $(input).attr('id', id);
                }, 1);
            });

요소에서 "이름"및 "ID"속성을 제거하고 1ms 후에 다시 할당합니다.

추가 autocomplete=off HTML에 속한다 input 요소는 그렇게해야합니다.

이것은 모든 브라우저에서 작동해야합니다

    <script type="text/javascript">
        var c = document.getElementById("<%=TextBox1.ClientID %>");
        c.select =
        function (event, ui) 
        { this.value = ""; return false; }
    </script>

추가 AutoCompleteType="Disabled" 텍스트 상자에

내 해결 방법은 비밀번호 필드를 일반 텍스트 상자로 만들고 jQuery를 사용하여 초점에 대한 비밀번호 필드로 전환하는 것입니다.

asp:TextBox runat="server" ID="txtUsername" />
<asp:TextBox runat="server" ID="txtPassword" />
<script>
    $("#txtPassword").focus(function () {
        $("#txtPassword").prop('type', 'password');
    });
</script>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top