I have asp.net MVC3 app where validations are done by adding validation attribute in model. e.g.
[Required(ErrorMessage = "Required field")]
[Display(Name = "SurveyName")]
[DataType(DataType.Text)]
public string SurveyName {get;set;}
Then I create text box in view
@Html.TextBoxFor(model => model.SurveyQuestions[i].SurveyName)
and add validation message
@Html.ValidationMessageFor(model => model.SurveyQuestions[i].SurveyName)
Scenario here is I create 5 textbox with for loop with same model property Surveyname and I want to validate only first textbox and no validations for rest of the textbox.
Is this possible?
Edit:
I used below code for rest of the textboxes but it validation occurs on these fields also.
@Html.TextBox("SurveyQuestions[" + i + "].Question", @Model.SurveyQuestions[i].Question)