The required validation of Kendo UI DropDownList not working some time so I'm going to share the code below for solving the same issues.
1. jQuery code sample.
2. HTML 5 code sample.
Table of Contents
1. jQuery code sample.
2. HTML 5 code sample.
Step 1 : for jquery example
//This
is used for validate to KendoDropDownList.
function validateKendoDropDownList(e) {
e.preventDefault();
var validator = $("#formSubmit").kendoValidator().data('kendoValidator');
var isValid = false;
if (!(validator.validate())) {
$("#lblMessage").text('Please select a
tenant...');
isValid = true;
}
return isValid;
}
$(document).ready(function () {
$('#btnRegisterToACompany').click(function (e) {
var isRequired = validateKendoDropDownList(e);
if (!isRequired) {
submtRegisterToACompany();
}
});
});
Step 1 : for HTML 5 code
<div id="formSubmit">
<section class="well" style="height: 250px !important">
<div class="form-horizontal
form-widgets col-sm-6">
<label id="lblMessage" style="color:red;"></label>
<div class="form-group">
<label for="language" class="control-label col-sm-4">Tenant</label>
<div class="col-sm-8
col-md-6">
<input id="ddlTenants" />
</div>
</div>
<div class="form-group">
<label for="language" class="control-label col-sm-4">Company</label>
<div class="col-sm-8
col-md-6">
<input id="ddlCompany" required />
</div>
</div>
<div class="form-group">
<label for="language" class="control-label col-sm-4"></label>
<div class="col-sm-8 col-md-6
text-align_right">
<input type="button" value="Register to a company" id="btnRegisterToACompany" class="btn btn-primary" />
</div>
</div>
</div>
</section>
</div>