Hello there,
I have 2 textbox on the screen, one is 'from amount' the other 'to amount'. The validation rule is 'from amount' should be less than 'to amount'.
Now my question is ,when user enters a pair of amounts in which 'from amount' is grater than 'to amount', how to make BOTH of the text boxes display with red border. And when user corrects the amounts (either by decreasing 'from amount' or increasing 'to amount' , how to make BOTH of the text boxes display without error appearance ?
Thanks
My code looks like this :
public partial class Rate : IDataErrorInfo
{
public Rate()
{
is_active = true;
registered = DateTime.Now;
}
#region FOR validation
public string Error
{
get
{
var properties = this.GetType().GetProperties();
foreach (var propertyInfo in properties)
{
string err = this[propertyInfo.Name];
if (!string.IsNullOrEmpty(err))
{
return err;
}
}
return string.Empty;
}
}
public string this[string propertyName]
{
get
{
string result = null;
if (result == null && "from_amt" == propertyName)
{
if (from_amt > to_amt)
{
result = Resources.Validation.Rate_from_amount_value;
}
}
if (result == null && "to_amt" == propertyName)
{
if (from_amt > to_amt)
{
result = Resources.Validation.Rate_to_amount_value;
}
}
return result;
}
}
#endregion
}
}