Is there a way of centrally setting Html.BeginForm to be autocomplete=off?
asp.net-mvc, asp.net-mvc-3, asp.net-mvc-4, razor
Solution
You can use jQuery(or Javascript) to apply attributes to your input tags.
Sample code below:
$(document).ready(function () { $("input").attr("autocomplete", "off"); });
You can put the script in your master layout to apply globally
Credits: https://stackoverflow.com/a/8617866/1027250
Problem
I need to disable autocomplete on the forms as we are getting some very odd values in there, including what looks like form field names. So until we understand this more we think it prudent to disable this feature. Obviously we can switch it off for each form like so: ``` Html.BeginForm("Create","Report", FormMethod.Post, new { autocomplete="off"})) ``` However is there a more centralised approach to do this ie default "BeginForm" to be autocomplete=off. Otherwise we would need to changes a lot of forms individually. Many thanks in advance.