dubs
dubs

Reputation: 6521

Remote Validation with MVC3

I've just been reading the article on MSDN about remote validation. This is great, but it only shows validating a specific property value.

Is there a way I can pass other values from my model into the validation for a particular property? For example, let's say that a user wants to cancel a number of items off an order - they should be prevented from entering a figure greater than the original order amount.

Thanks

Upvotes: 1

Views: 1272

Answers (2)

Bcelik
Bcelik

Reputation: 1216

Well, i am nit sure if you mean this, but you can use AdditionalFields with your RemoteValidation attribute.

Remote Validation in ASP.Net MVC 3: How to use AdditionalFields in Action Method

Upvotes: 1

Jakub Konecki
Jakub Konecki

Reputation: 46008

No, you can't.

Brad Wilson:

At this time, only property level validators can emit client-side validation (as that lines up much better with the idea of input validation in the form of the browser... there is no "model" to speak of, from the browser's point of view).

Stuart Leeks:

I don't believe you can hook up client validation with IValidatableObject

Upvotes: 2

Related Questions