Is there a W3C valid way to disable autocomplete in a HTML form?

后端 未结 18 1494
心在旅途
心在旅途 2020-11-22 05:58

When using the xhtml1-transitional.dtd doctype, collecting a credit card number with the following HTML



        
18条回答
  •  庸人自扰
    2020-11-22 06:36

    if (document.getElementsByTagName) {
        var inputElements = document.getElementsByTagName("input");
        for (i=0; inputElements[i]; i++) {
            if (inputElements[i].className && (inputElements[i].className.indexOf("disableAutoComplete") != -1)) {
                inputElements[i].setAttribute("autocomplete","off");
            }
        }
    }
    

提交回复
热议问题