In my model I have:
[Required]
[DataType(DataType.EmailAddress)]
public string EmailAddress {get; set;}
However in my view (source) this renders as:
<label for="EmailAddress">EmailAddress</label>
<input data-val="true" data-val-required="The EmailAddress field is required"
id="EmailAddress" name="EmailAddress" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="EmailAddress" data-valmsg-replace="true">
I thought this should have rendered with type="email" rather than type="text" - so when validating on the client side, it does not pickup if the email is not in a valid format.
EDIT
Further more, when I call if (ModelState.IsValid) it returns true, even if the email address is not in the correct format. so even if the browser does not support HTML5, I would have thought that the IsValid in the controller would then have enforced the validation - is that not the case?
Is there something else I need on my model, to force type="email" so this correctly checks for a valid email address?
Thanks you,
Mark