1

Good day,

I am using MVC4 and Foolproof validation.

I am trying to validate a field based on the values of at least 2 other fields.

public int pos1 { get; set; }
public int pos2 { get; set; }

[RequiredIf("pos1",1,ErrorMessage="some error message" )]
public int? IrdKsOption { get; set; }

RequireIf can on be specified once. RequireIf only takes 1 fieldname and value.

How would i go about doing something like this

public int pos1 { get; set; }
public int pos2 { get; set; }

[RequiredIf("pos1,pos2",[1,5],ErrorMessage="some error message" )]
public int? IrdKsOption { get; set; }

so that if pos1=1 and pos2=5 validation should fail

GeoSaffer
  • 143
  • 12
  • 1
    You will need to write you own validation attribute that implements `IClientValidatable` - refer [this article](http://www.devtrends.co.uk/blog/the-complete-guide-to-validation-in-asp.net-mvc-3-part-2) to get you started –  Feb 29 '16 at 22:08
  • thank you, this seems to have helped my issue – GeoSaffer Nov 22 '16 at 18:51

0 Answers0