0

I need to add dynamic text boxes in mvc view and validate it in client side and in server side. Usually we make property in model and set annotation for required and max length then set textbox field with same name of this property in view but how to make dynamic properties with dynamic annotations for dynamic generated text boxes? Or how to validate dynamic generated field in server side and in client side? I searched a lot but I didn't find any powerful solution to my issue. I tried this code to make validation in client side

$("#myform").validate();
         $('#NameT').rules('add', { required: true, messages: { required: 'The Foo field is required' } });

but this validation canceled other validations in same view (I mean other validation for static fields because my view contains static and dynamic fields static field I validate it in model by set annotations)

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

0 Answers0