Declined
Last Updated: 02 Nov 2022 15:20 by ADMIN
Lauren
Created on: 16 Jun 2022 12:17
Category: Checkbox
Type: Bug Report
1
The CheckBox TagHelper does not render the attribute "required" and a custom class

### Bug report

The CheckBox TagHelper does not render the attribute "required" and a custom class.

### Reproduction of the problem

The CheckBox TagHelper definition:

<kendo-checkbox id="KendoCheckboxRequiredByHtml" class="form-check-input" required>
</kendo-checkbox>

It generates the following markup:

<input id="KendoCheckboxRequiredByHtml" name="KendoCheckboxRequiredByHtml" type="checkbox" value="true" data-role="checkbox" class="k-checkbox k-checkbox-md k-rounded-md">
<input name="KendoCheckboxRequiredByHtml" type="hidden" value="false">

A sample for reproduction is attached.

### Expected/desired behavior

The attribute "required" and the class "form-check-input" to be set to the generated input element.

### Environment

* **Kendo UI version: 2022.2.510
* **Browser: [all]

Attached Files:
1 comment
ADMIN
Viktor Tachev
Posted on: 02 Nov 2022 15:20

Hi Lauren,

We have researched the issue and modifying the current behavior would lead to a breaking change in the way Checkboxes and validation work. 

We can suggest implementing a custom validation rule to validate required checkboxes as shown below:

            $.extend(true, kendo.ui.validator.rules, {
                requiredcheckbox: function (input) {
                    if (input.is('[type="checkbox"][data-val-required="true"]')) {
                        return input.is(":checked");
                    }
                    return true;
                }
            });

Regards,
Viktor Tachev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.