In my view model I have the following:
[Required]
[Display(Name = "Email")]
[DataType(DataType.EmailAddress)]
public string[] EmailAddresses { get; set; }
and in my view
for (int i = 0; i < Model.EmailAddresses.Length; i++)
{
<div class="form-group">
@Html.LabelFor(m => m.EmailAddresses[i], new {@class = "col-md-2 control-label"})
<div class="col-md-10">
@Html.TextBoxFor(m => m.EmailAddresses[i], new { @class = "form-control" })
</div>
</div>
}
I want all of the email addresses to adhere to the data type DataType.EmailAddress and have the label Email. I also want at least one email address to be required.
Is this possible to accomplish using attributes?