I have a form on which there is checkbox control. For some reason the kendo validator always considers the checkbox a required field and considers a non-checked state as invalid. How can I get the validator to ignore the checkbox? As you can see, the field, IsTerminated is not marked required.
<form id="frmEmployee" method="post">
<div class="control-grid">
<div class="col-1-label">
@Html.LabelFor(m => m.Id, "Employee Id: ")
</div>
<div class="col-1-control">
@Html.Kendo().TextBoxFor(m => m.Id).HtmlAttributes(new { @readonly = "", @required = "", @validationMessage = "Id is required" })
</div>
<div class="col-2-label">
@Html.LabelFor(m => m.FirstName, "First Name: ")
</div>
<div class="col-2-control">
@Html.Kendo().TextBoxFor(m => m.FirstName).HtmlAttributes(new { @required = "", @validationMessage = "First Name is required" })
</div>
<div class="col-3-label">
@Html.LabelFor(m => m.LastName, "Last Name: ")
</div>
<div class="col-3-control">
@Html.Kendo().TextBoxFor(m => m.LastName).HtmlAttributes(new { @required = "", @validationMessage = "Last Name is required" })
</div>
<div class="col-1-label">
@Html.LabelFor(m => m.MiddleName, "Middle Name: ")
</div>
<div class="col-1-control">
@Html.Kendo().TextBoxFor(m => m.MiddleName)
</div>
<div class="col-2-label">
@Html.LabelFor(m => m.PreferredName, "Preferred Name: ")
</div>
<div class="col-2-control">
@Html.Kendo().TextBoxFor(m => m.PreferredName)
</div>
<div class="col-3-label">
@Html.LabelFor(m => m.Email, "Email: ")
</div>
<div class="col-3-control">
@Html.Kendo().TextBoxFor(m => m.Email).HtmlAttributes(new { @required = "", @validationMessage = "Email is required" })
</div>
<div class="col-1-label">
@Html.LabelFor(m => m.HireDate, "Hire Date: ")
</div>
<div class="col-1-control">
@Html.Kendo().DatePickerFor(m => m.HireDate).HtmlAttributes(new { @required = "", @validationMessage = "Hire Date is required" })
</div>
<div class="col-2-label">
@Html.LabelFor(m => m.IsTerminated, "Terminated: ")
</div>
<div class="col-2-control">
@Html.Kendo().CheckBoxFor(m => m.IsTerminated)
</div>
<div class="col-3-label">
@Html.LabelFor(m => m.TerminationDate, "Termination Date: ")
</div>
<div class="col-3-control">
@Html.Kendo().DatePickerFor(m => m.TerminationDate)
</div>
<div style="display: none;">
@Html.Kendo().DatePickerFor(m => m.CreatedDate)
</div>
</div>
</form>
On page load I have:
$(document).ready(function () { $("#frmEmployee").kendoValidator(); });
And before I submit my data to the server I have a check:
let validator = $('#frmEmployee').kendoValidator().data('kendoValidator'); if (validator.validate()) { // ... }
validator.validate() always returns false if IsTerminated is not checked. IsTerminated is a non-nullable bool.