Switch validation message does not dissappear

3 posts, 1 answers
  1. Robert
    Robert avatar
    16 posts
    Member since:
    Mar 2015

    Posted 16 Oct 2017 Link to this post

    Hello.  I noticed a bug where the validation message does not disappear for the mobile switch, but does for a regular switch.

    Dojo: http://dojo.telerik.com/ISuvI

    Can you fix this please?

  2. Answer
    Tsvetina
    Admin
    Tsvetina avatar
    2112 posts

    Posted 18 Oct 2017 Link to this post

    Hi Robert,

    This happens because the state of the underlying input element of the Switch is changed in code when you click the Switch widget. Input elements do not fire their change event when their value is changed in code and the Validator is listening for change events in the inputs that it is tied to. As there is no such event when clicking the Switch, validation is not triggered.
    The simplest solution is to handle the Switch change event and manually trigger validation:
    $("#accept_box").kendoMobileSwitch({
      onLabel: "YES",
      offLabel: "NO",
      change: function(e){
        var validator = $("#validator").data("kendoValidator");
        validator.validate();
      }
    });

    Here is the modified Dojo, where you can see the result:
    http://dojo.telerik.com/@tsveti/oDiDaN

    Regards,
    Tsvetina
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Robert
    Robert avatar
    16 posts
    Member since:
    Mar 2015

    Posted 18 Oct 2017 in reply to Tsvetina Link to this post

    Thank you, this works for me.
Back to Top