1

I am very new to MVC and I am using MVC 3 in our Project..

I implemented Model level validation using IValidateObject..and I created the Validate method with some validation logic on my model...

I saw some other interface called Iclientvalidatable for calling validation methods from jquery validation(client side)..

Now I am trying to call the Validate method from client side...Is it possible??

Do I need to implement Iclientvalidatable interface on same model and needs to write the same logic in this method also??

Or Can I directly access the validate method from IClietnValidatable method??

My goal is accessing the validate method logic from client side..If its not possible to do..then i need to write same logic on client side also...

Please help me..thanks..

Sunny43
  • 129
  • 1
  • 4
  • 15
  • Possible duplicate of [IValidatableObject in MVC3 - client side validation](http://stackoverflow.com/questions/4748703/ivalidatableobject-in-mvc3-client-side-validation) – KyleMit Feb 21 '17 at 16:47

2 Answers2

1

If you want custom client side validation you need to implement the IClientValidatable interface but the actual validation logic should be done using javascript. And here's another example.

Community
  • 1
  • 1
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • this one works fine if we want to compare two fields...i want to do a group validation like "if any one of them is required"..and this field is in conjunction with those two date fields..how can i handle this kind of scenarios..i have already did the logic on model level..but how to use that code for Iclientvalidatable interface...thanks for your help.. – Sunny43 Apr 26 '11 at 15:38
  • @Sunny43, please provide a specific example of what you are trying to achieve. – Darin Dimitrov Apr 26 '11 at 15:45
1

You cannot link class level validators to client side validation.

See IValidatableObject in MVC3 - client side validation

Community
  • 1
  • 1
Dan
  • 3,229
  • 2
  • 21
  • 34
  • ok. I got it. I go with normal Jquery validation and its very simple to implement..Thanks for your support.... – Sunny43 Apr 27 '11 at 15:39