How can I share one validation message between two controls?

2 posts, 0 answers
  1. Glenn
    Glenn avatar
    16 posts
    Member since:
    Sep 2007

    Posted 22 Jan 2014 Link to this post

    I'm using MVC.

    I have two fields - both IntegerTextBoxes (Html.Kendo().IntegerTextBoxFor....)

    These two values are to be validated so that the value in field 1 has to be <= the value in field 2.  I've got a custom validator for this.

    So supposing I specify 5 in both fields.
    I then change field 1 to equal the value 6 and tab off.  The error is shown against field 1.
    I then enter field 2 and tab off.  The error is also shown against field 2 now.  So both fields are showing the error.
    If I adjust field 1 to equal 5 again and tab off, the error message disappears against field 1 but it remains against field 2 until I tab in and out of that too.

    Is there an easy way to link these into one validation with one validation message?


  2. Glenn
    Glenn avatar
    16 posts
    Member since:
    Sep 2007

    Posted 22 Jan 2014 Link to this post

    OK found the solution.


    <span class="k-invalid-msg" data-for="Baby.NoOfBirths"></span>

    and then in the relevant validator rule:

    var e = $("span.k-invalid-msg[data-for='Baby.NoOfBirths']");
    e.hide();
  3. Kendo UI is VS 2017 Ready
Back to Top