I've got a model field like so:
[Required(ErrorMessage = "Required!")]
[Display(Name = "Some ID")]
[DataType(DataType.Text)]
[RegularExpression(@"SomeRegexHere"]
public string someId { get; set; }
On my view, I have a form for updating the model. Something like this:
<div class="form-group">
@Html.LabelFor(model => model.someId, htmlAttributes: new { @class = "control-label" })
@Html.EditorFor(model => model.someId, new { htmlAttributes = new { type = "number", @class = "form-control" } })
@Html.ValidationMessageFor(model => model.someId, "", new { @class = "text-danger" })
</div>
Say on this same view I can fill in this field in order to submit it to the database, but I may also fill in some other field to retrieve an entry in the database by this value. However, I'd like to apply the same validations to both fields. Without creating a dummy model attribute, can I display validation errors for both fields?