jQuery的 - 验证剑道的DropDownList与显示:无风格 [英] jQuery - validate kendo dropdownlist with display:none style
问题描述
在我看来,我有一个剑道的DropDownList。从来就实现jQuery验证在视图中插入这些脚本:
In my view I have a kendo dropdownlist. I´ve implement jQuery validation inserting these scripts in the view:
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
我已经设置属性为实体需要和所有我需要进行验证。
I've set the property as Required in the entity and all I need to perform the validation.
型号:
[Required(ErrorMessage = "Campo Tipo de Llenado es necesario")]
public int TipoLlenado { get; set; }
查看:
@(Html.Kendo()
.DropDownListFor(model => model.pedidoGranelAutoEs.TipoLlenado)
.BindTo(new SelectList(cmbTipoLlenado.Select(s => new { Key = s.IdDatoMaestro, Value = s.ValorPortal }), "Key", "Value"))
.Events(events =>
{
events.Select("selectTipoLlenado");
})
.OptionLabel(Idioma.Shared.Pedidos_SeleccioneOpcion)
)
@Html.ValidationMessageFor(model => model.pedidoGranelAutoEs.TipoLlenado)
问题是,如果我检查与Chrome的网页,并删除了显示:无从剑道的DropDownList(用剃刀)所产生的输入方式,然后preSS提交按钮确认工作正常。
The thing is that if I inspect the web with Chrome and remove the "display:none" style from the input generated by the kendo DropDownList (using Razor), and then press the Submit button the validation works fine.
我试过下面的解决方案,而结果是:
I've tried the following solutions without result:
$(document).ready(function () {
$('#formu').validate({
ignore: []
});
}
或
$(document).ready(function () {
$('#formu').validate({
ignore: ':hidden'
});
}
或
$.validator.setDefaults({ ignore: []});
或
$.validator.setDefaults({ ignore: ':hidden' });
任何建议??
在此先感谢!
推荐答案
我发现的错误。
这是我写的行:
I've found the mistake. It was that I have to write the line:
$.validator.setDefaults({
ignore: []
});
$(文件)。就绪(函数()以外{...}
这篇关于jQuery的 - 验证剑道的DropDownList与显示:无风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!