[英]jQuery validation not working on webforms form
I have this in a separated js file 我在单独的js文件中有这个
$(function () {
var form = $("#formNovoArtigo").validate({
rules: {
'[id*=txtCadenciaMensal]': {
required: true,
digits: true
}
},
messages: {
"[id*=txtCadenciaMensal]": "Insira a Cadência Mensal"
},
});
});
however i even tried to see what's going on with a try catch but it won't trigger so I'm not sure what am i doing wrong. 但是我什至试图查看尝试捕获的情况,但是它不会触发,所以我不确定我在做什么错。 I added rule to a textbox to accept only numbers but nothing happens.
我将规则添加到文本框中以仅接受数字,但什么也没有发生。 no message not nothing
没有消息就没有
Edit. 编辑。
Here's scripts references 这是脚本参考
bundles.Add(new ScriptBundle("~/Bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/Bundles/adminlte").Include(
"~/AdminLTE/dist/js/adminlte.js",
"~/AdminLTE/plugins/bootstrap/js/bootstrap.bundle.js"));
bundles.Add(new ScriptBundle("~/Bundles/jqueryui").Include(
"~/Scripts/jquery-ui-{version}.js"));
bundles.Add(new ScriptBundle("~/Bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));
bundles.Add(new ScriptBundle("~/Bundles/js").Include(
"~/Scripts/MasterPage/menu-selection.js",
"~/Scripts/Pages/DataTables.js",
"~/Scripts/Pages/Validation.js"));
Ah I found the error, i forgot to write input before the ID... Works 100% in ASP.NET 4.5 啊,我发现了错误,我忘了在ID之前写输入...在ASP.NET 4.5中可以100%工作
$(function () {
$('form').validate({
debug:true
});
$('input[id*=txtCadenciaMensal]').rules('add', {
required: true,
messages: {
required: 'Some custom message for the username required field'
}
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.