HTML을 작성할 때 간혹 보안상, 또는 기타 이유로 이전 입력 내용을 표시하지 않도록 하고 싶을 때가 있다.

그럴 때 많이 쓰는 속성이 바로 autocomplete="off"인데...

알고보니 이게 제대로 쓰는 형식이 아니었다.

특히 Microsoft Edge와 같은 최신 브라우저에서는 autocomplete="off"가 안 먹는다.

 

원래 autocomplete의 용도는 아래 사이트에 잘 나와 있다.

 

>> 참조: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete

 

HTML attribute: autocomplete - HTML: HyperText Markup Language | MDN

The HTML autocomplete attribute lets web developers specify what if any permission the user agent has to provide automated assistance in filling out form field values, as well as guidance to the browser as to the type of information expected in the field.

developer.mozilla.org

요약하자면, 브라우저에서 자주 쓰는 입력 양식을 브라우저 캐시 등에 저장해 두었다가 목록으로 불러서 직접 타이핑 없이 입력할 수 있도록 해 주는 편의 속성으로, 특정 예약어를 사용하면 해당 예약어로 기록된 이전 입력 문구가 나타나도록 되어 있다.

 

autocomplete="off"를 쓰면 어지간한 브라우저에서는 자동 입력 양식이 적용되지 않아 이전 입력 내용이 나타나지 않는다. 다만 모든 브라우저에서 동일하게 적용되게 하려면 autocomplete="off"로는 안되며, 위 참조 사이트에 없는 새로운 문구를 넣어서 브라우저에 기록되어 있는 이전 입력 문구가 표시되지 않도록 해야 한다.

 

 

>> 참조: https://stackoverflow.com/questions/58694161/auto-complete-off-is-not-working-on-edge-browser

 

auto complete off is not working on edge browser

I am trying to submit the form but It won't. It is auto-fill the input area after submitting once. However, after auto-fill the input it does not enable the submit button. As it works on the rest ...

stackoverflow.com

 

위 사이트에 잘 나와 있듯, autocomplete="autocomplete_off_randString" 처럼, 임의의 문구를 실시간 랜덤하게 생성해서 만들어 붙이면 된다. 여기서 randString은 고정된 문자열이 아니고 말 그대로 유일한(unique) 임의의 문자열을 만들어 넣으라는 뜻이다, 기존에 썼던 내용과 중복되지 않도록. 그게 어렵다면 해당 입력 항목의 id 값이라도 유일한 값으로 쓰거나.

 

끝.

 

 

 



Posted by 떼르미
,


자바스크립트를 허용해주세요!
Please Enable JavaScript![ Enable JavaScript ]