0

Here I have three properties Like

Public Class Addition{
public Int Val1{get;se;}
public Int Val2{get;se;}
public Int Val3{get;se;}
}

In .cshtml Val1=10;Val2=20; If User Entre Val3=30 Then How can i validate Val3 Value Should Be LessThan or Equal to 30 Beacause (10+20=30)

  • use a custom validation attribute. I recommend you fluent validation .NET. refer this link https://stackoverflow.com/questions/8906228/how-to-validate-one-field-related-to-anothers-value-in-asp-net-mvc-3 – SUNIL DHAPPADHULE Jan 28 '20 at 05:54
  • Could you please give hint how can i bind three values at a time –  Jan 28 '20 at 05:55

1 Answers1

1

What is the problem are you facing to solve it. it shouldn't be complex You can use

if(Val3 > (Val1 + Val2))                                                             
{             
  //Show Your Message
  return;
}

Upvote if helps

Prashant Pimpale
  • 10,349
  • 9
  • 44
  • 84
Shyam
  • 182
  • 1
  • 14