Remote validation happens only for 1st element. For other elements null value goes in the parameter so no validation happens. Why is it passing null values for rest of the rows? Only row 0 values are passed. What am I doing wrong? Or is there alternative to do the validation?
My model:
public class AdminModel
{
....
public List<Detail> ManageDetails { get; set; }
}
public class Detail
{
public string Id { get; set; }
[Remote("CheckValidity", "", AdditionalFields = "InDate, OutDate", ErrorMessage = "Time is invalid.")]
public string InTime { get; set; }
}
The view is rendered with a for loop:
@for (int index = 0; index < Model.ManageDetails.Count; index++)
{
@Html.HiddenFor(model => model.ManageDetails[index].Id)
@Html.TextBoxFor(model => model.ManageDetails[index].InTime})
@Html.ValidationMessageFor(model => model.ManageDertails[index].InTime)
}