This is a migrated thread and some comments may be shown as answers.

Switch validation message does not dissappear

2 Answers 198 Views
Switch (Mobile)
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 16 Oct 2017, 03:46 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetina
Telerik team
answered on 18 Oct 2017, 11:16 AM
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.
0
John
Top achievements
Rank 1
answered on 18 Oct 2017, 01:52 PM
Thank you, this works for me.
Tags
Switch (Mobile)
Asked by
John
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
John
Top achievements
Rank 1
Share this question
or