Reputation: 5232
I have normal razor as well as kendo controls in my form, i am facing some problem while trying to validate kendo dropdownlist using jquery validate plugin. The below is my code.
@(Html.Kendo().DropDownList()
.Name("color")
.DataTextField("Text")
.DataValueField("Value")
.BindTo(new List<SelectListItem>() {
new SelectListItem() {
Text = "Select Value",
Value = ""
}, new SelectListItem() {
Text = "Black",
Value = "2"
},
new SelectListItem() {
Text = "Orange",
Value = "3"
},
new SelectListItem() {
Text = "Grey",
Value = "4"
}
}).Value("")
.HtmlAttributes(new { style = "width: 100%" })
)
<input type="submit" value="Submit" />
now i have used my jquery validate like this
$(document).ready(function () {
$("#dropDownForm").validate({
rules: {
color: "required"
},
highlight: function (element) {
alert('highlight');
},
unhighlight: function (element) {
alert('unhighlight');
},
errorPlacement: function (error, element) {
return false;
},
debug: true
});
});
but i am not able to validate the dropdown list and both highlight and unhighlight event of jquery validate plugin is not getting called. Any help is appreciated. Thank you
Upvotes: 3
Views: 5611
Reputation: 2509
Following is recommended
Put $.validator.setDefaults({ ignore: '' }); not inside $(document).ready
jQuery Validate - Enable validation for hidden fields
http://www.telerik.com/forums/mvc-client-validation-not-working
Upvotes: 3