0

On a certain screen of our application, we have two dates which both have a remote validation attribute on them in the viewmodel. The attribute will compare the dates and see if they are filled in.

The validation logic is working correctly, but clearing the validation messages is giving us some issues.

Example:

Date 1 -> 05/05/2015

Date 2 -> 06/06/2015

Date 2 gets emptied => Validation on date 2 triggers and a message appears above the textbox of date 2

We change the value of date 1 => Validation on date 1 triggers because date 2 is empty

We fill in date 2 => Validation message of date 2 disappears but validation message of date 1 stays

Is there a way to make the validation on date 1 disappear as well, when the value of date 2 gets filled in correctly?

fool-dev
  • 7,671
  • 9
  • 40
  • 54
  • Do these two have the same `name` attribute in html? – Jasen Dec 09 '15 at 18:11
  • Can we see the form and the validation? – ZeroBased_IX Dec 09 '15 at 19:27
  • maybe you can post your code, as in your view controls ? – DaniDev Dec 09 '15 at 19:46
  • 1
    Why do you think you need Remote validation for this task? You seem to be wanting to compare 2 values which exist in the form, in which case Remote validation is not the correct approach. What rules are you actually applying? –  Dec 09 '15 at 21:27
  • You will need a custom validation attribute, this has been well explained and documented here http://stackoverflow.com/questions/8906228/how-to-validate-one-field-related-to-anothers-value-in-asp-net-mvc-3 – timothyclifford Dec 10 '15 at 09:43

0 Answers0