Possible Duplicate:
Is there a W3C valid way to disable autocomplete in a HTML form?
Is there a way I can prevent a browser from not remembering the content of a text field? The problem is that the field contains a value such as 100, and then gets appended a currency symbol such as € making it 100 €
. If I click on the field, my widget removes the currency and I can edit the bare number, and when I blur it displays the currency again. Everything works fine until you hit F5 and then you end up having 100 € €
because the browser restored the original value 100 €
it had when the reload happened, and the widget re-added it.
For browsers that support it, there's the new autocomplete
attribute. From the link:
The
autocomplete
attribute is an enumerated attribute. The attribute has three states. Theon
keyword maps to the on state, and theoff
keyword maps to the off state. The attribute may also be omitted. The missing value default is the default state.The off state indicates either that the control's input data is particularly sensitive (for example the activation code for a nuclear weapon); or that it is a value that will never be reused (for example a one-time-key for a bank login) and the user will therefore have to explicitly enter the data each time, instead of being able to rely on the UA to prefill the value for him; or that the document provides its own autocomplete mechanism and does not want the user agent to provide autocompletion values.
...although in the specific case you describe, I think I'd probably just keep the € symbol outside the field's value in the first place. You can put it next to the field, or superimpose it on the field using CSS (for instance, put it after the field in the markup and then use position: relative; left: -3em
, that sort of thing). But if you really want to prevent the browser's auto-filling, autocomplete
is one tool for the toolchest.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With