I have a few text boxes on my page and find it very annoying the auto complete functionality. Is there any way to remove this from my site?
I have a few text boxes on my page and find it very annoying the auto complete functionality. Is there any way to remove this from my site?
This is how you can do this
autocomplete="new-text"
Add inside you input box or textarea
autocomplete="off" do not support instead of that use this 'autocomplete="new-password"'
You can use jQuery to add the autocomplete attribute after the page loads. That's the best way I found to force Chrome to listen.
<script type="text/javascript" language="javascript">
jQuery(function() {
jQuery('#my_input').attr('autocomplete', 'off');
});
</script>
<input type="text" name="my_input" id="my_input">
autocomplete="off" works in Firefox, but it doesn't work in Chromium browsers on Ubuntu, so you need to check if the browser is a Chromium browser, and if it is use autocomplete="disabled", otherwise use autocomplete="off".
var is_chrome = /chrome/.test( navigator.userAgent.toLowerCase() );
$("#mobile").prop("autocomplete", is_chrome ? 'disabled' : 'off');
Simplest way:
Remove name attribute, and add always a different string in autocomplete.
$(document).ready(function () {
setTimeout(function () {
var randomicAtomic = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
$('input[type=text]').removeAttr('name');
$('input[type=text]').attr('autocomplete', randomicAtomic);
}, 1000);
})
use autocomplete = "off" in Html.BeginForm
@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post, new { @id = "myForm", @autocomplete = "off" }))
{
@Html.EditorFor(model => model.field, new { htmlAttributes = new { @class = "text-box form-control" } })
<input type="submit" value="Save" />
}