I have a model
[Required(ErrorMessage = "Email required")]
[DataType(DataType.EmailAddress, ErrorMessage = "Please enter valid email address")]
public string Email { get; set; }
From that I want the view to return
<input type="email" value="" name="Email" id="Email" data-val-required="Email required" data-val="true">
and also option to use jquery.validate.unobtrusive on the email address without including a regx.
But by default the type="text" and I do not get email validation. I only get required field validation What is the easiest way to do this?
html5.js
or http://deanhume.com/Home/BlogPost/asp-net-mvc-html5-toolkit/29 (I tried this it make the type="email" but ignores by data Annotations so I miss out on my client side validation)
or just make a HTML helper
or can I just manually override the type and add data-val-email to my class
You may take a look at the following blog post.
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