简体   繁体   中英

Odd Registration Form Behaviour

On my registration page I have the following defined in order for users to enter a display name value for their profile. It's defined like this:

<input id="DisplayName" type="text" value="" name="DisplayName" data-val-required="Use must provide a display name" data-val-length-max="50" data-val-length="The field Display name must be a string with a maximum length of 50." data-val="true">

I can understand FF using my email address for the "Email" field but I've never used this value in the "DisplayName" field and the very reason I have a display name field is to make sure the users email address is never used as the display name. Very confusing.

The property on the model is defined like this:

[Required(ErrorMessage = "...")]
[Display(Name = "Display name", Description="...")]
[StringLength(50)]
public string DisplayName { get; set; }

Why would FF insert the email in DisplayName field?

It looks like Firefox is making a 'best guess' on how to populate that field based on the input element and text around it, but it's getting it wrong. You can disable autocompletion by adding the property autocomplete="off" .

In Razor this will look like:

@Html.TextBoxFor(model => model.DisplayName, new { autocomplete = "off" })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM