[英]Prevent from auto fill form data
I am facing a problem related to auto fill in form. 我遇到与自动填写表格有关的问题。 Actually i am running a trust charity website which collects fund from donor. 实际上,我正在运行一个信托慈善网站,该网站从捐助者那里收取资金。
Problem : 问题:
When i have entered a donation for one cause and again i want to enter donation for the same cause but with different credit card detail. 当我出于某种原因输入捐赠后,我又想为同一原因输入捐赠但使用不同的信用卡详细信息。 then i am strange the form where i need to enter detail card related is retained all of the information from the previous donation so everything was entered. 那么我很奇怪,我需要输入与详细卡相关的表格被保留了先前捐赠的所有信息,因此一切都被输入了。
I have tried autocomplete="off"
in form and also in input. 我在表单和输入中都尝试过autocomplete="off"
。
Try adding a unique identifier to the beginning or end of the id's or names of the form elements. 尝试在ID的开头或结尾或表单元素的名称中添加唯一标识符。
Alternatively there is this: 另外,这是:
autocomplete = ”off” is not valid markup with XHTML Transitional, which is a common DOCTYPE.Use this to keep a valid markup from autocomplete =“ off”不是XHTML Transitional的有效标记,它是一种常见的DOCTYPE。使用此标记可防止
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”);
}
}
}
From http://css-tricks.com/snippets/html/autocomplete-off/ 从http://css-tricks.com/snippets/html/autocomplete-off/
rename the input for each pageload. 重命名每个页面加载的输入。 generate a prefix, and put it in a hidden field in the form. 生成一个前缀,并将其放在表单的隐藏字段中。
$prefix = date("U"); //lets use unix time for this.
... ...
<input type="hidden" name="prefix" value="<?php echo $prefix; ?>"/>
<input type="text" name="<?php echo $prefix; ?>_cardnumber" />
... ...
And when processing look for 而当寻找
$_POST[$_POST['prefix'].'_cardnumber']
If this is Google Chrome then it actually has a feature which ignores autocomplete settings from the current web form and will actually pull data from it's own "personal program cache" and populate the fields for you as a convenience. 如果这是Google Chrome,那么它实际上具有忽略当前Web表单中自动完成设置的功能,并且实际上将从其自身的“个人程序缓存”中提取数据,并为您提供方便。 It also does this when it recognizes address fields. 当它识别地址字段时,它也会这样做。 Thomas Martin Klein's answer will probably work best but I have not tested it before so Chrome may be smart enough to recognize your algorithm anyways. 托马斯·马丁·克莱因(Thomas Martin Klein)的答案可能效果最好,但我之前没有对其进行过测试,因此Chrome可能足够聪明,无论如何都能识别您的算法。 Good luck! 祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.