2

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.

SamJolly
  • 6,347
  • 13
  • 59
  • 125
  • 1
    This looks somewhat similar to what you want http://stackoverflow.com/questions/6387427/rolling-my-own-html-beginform – Kunukn Apr 15 '14 at 19:23

2 Answers2

6

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

Community
  • 1
  • 1
Yorro
  • 11,445
  • 4
  • 37
  • 47
1

That is a FormExtension provided by ASP.NET and you know the functionality of it so I won't go in deep.

http://msdn.microsoft.com/en-us/library/system.web.mvc.html.formextensions.beginform(v=vs.118).aspx

Go to the above link to learn about this Helper. But note that it is a built-in feature and you cannot edit it until you edit the source code for that.

So, the answer would be that you need to Edit the source code file for ASP.NET Web Helpers (System.Web.Mvc.Html)

http://msdn.microsoft.com/en-us/library/system.web.mvc.html(v=vs.118).aspx

If you can edit it, then you can have that done. Otherwise you'll have to write that code for each form.

Afzaal Ahmad Zeeshan
  • 15,669
  • 12
  • 55
  • 103