【发布时间】:2016-08-02 19:55:57
【问题描述】:
我的表单中有普通剃须刀和剑道控件,我在尝试使用 jquery validate 插件验证剑道下拉列表时遇到了一些问题。 以下是我的代码。
@(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" />
现在我已经像这样使用我的 jquery 验证了
$(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
});
});
但我无法验证下拉列表,并且 jquery validate 插件的突出显示和取消突出显示事件都没有被调用。 任何帮助表示赞赏。 谢谢
【问题讨论】:
-
既然您已经在使用 Kendo UI,为什么不能使用 Kendo 验证器:demos.telerik.com/kendo-ui/validator/index
-
@Vijai 我不想使用剑道验证器的原因是因为我有很多控件是剃须刀控件,并且我的项目中要求仅使用剑道控件进行下拉和剑道可拖动...你能帮我了解如何使用 jQuery 验证器验证剑道下拉菜单,正如我在上面的问题中明确建议的那样
标签: kendo-ui jquery-validate kendo-asp.net-mvc