I can do this easily using a TextBoxFor
but how do I do it with an EditorFor
?
I figured using the DataAnnotation [DataType(DataType.EmailAddress)]
but that doesn't do it.
I don't quite understand what the DataType
annotation actually does because it doesn't seem to do anything at all at first glance.
You can override the HTML Attributes, to which a browser will fallback to type='text'
if they do not support it:
@Html.TextBoxFor(m => m.Email, new { @type = "email" })
it seems to be supported now.
@Html.EditorFor(model => model.Email, new { htmlAttributes = new { @class = "form-control", @type = "email" } })
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