Focus Widget on Label Click

The following example demonstrates how to focus the NumericTextBox when the label element is clicked.

<label for="numerictextbox">Number: </label>
<input id="numerictextbox" />
<script>
  $(function() {
    $("#numerictextbox").kendoNumericTextBox();

    //global click handler for all label elements
    $("label").click(function(e) {
       var label = $(this);
       var id = label.attr("for");
       var widget;

       if (id) {
           widget = kendo.widgetInstance($("#" + id), kendo.ui);

           if (widget) {
               e.preventDefault();
               widget.focus();
           }
       }
    });
  });
</script>

See Also

For more runnable examples on the Kendo UI NumericTextBox, browse its How To documentation folder.

In this article
Not finding the help you need? Improve this article