Hi Tanvi,
For this, you have to create a new validation attribute and then you need to apply this new attribute on your property. I already answered your last query you can refer that.
Pasting here the same answer-
[ListItems(2, int.MaxValue, ErrorMessage="At least two items, please!")]
public virtual IList<QuestionnaireAnswerBlock> Answers { get; set; }
Or, if you want full control, you could create your own custom validation:
[ListItems(2,6,ErrorMessage ="Minimum 2 and Maximum 6 columns are allowed")]
I'm using ListItems attribute on IList which shows a validation message. 'The field Answers is invalid'
I want to show a customised message. How to do it?
[ListItems(2,int.MaxValue)]
public virtual IList<QuestionnaireAnswerBlock> Answers { get; set; }