SCC*_*SCC 1 javascript jquery jquery-validate
我有这个多步骤表格,我想验证(以确保指定正确格式的视频文件,并填写所有必填字段).我想使用jquery.validate插件来实现这一点.
问题是在我添加此验证代码之前,"上传"按钮工作正常.我相信我的代码出了问题导致"上传"按钮停止工作.我在这里包括一个小提琴:http://jsfiddle.net/NZr4n/
我相信这是导致错误的部分.有人可以帮忙吗?
$('#msform').validate({
rules: {
videoFile: {
required: true,
extension:'mov|mp4|mpeg|wmv'
}
videoTitle: {
required: true,
}
videoDescription: {
required: true,
}
},
messages: {
videoFile: "Please specify a file",
videoTitle: "Title is required"
videoDescription: "Description is required"
}
});
if ((!$('#msform').valid()) {
return false;
}
Run Code Online (Sandbox Code Playgroud)
我在jsfiddle上看了你的代码,我注意到一些看似很小的语法问题,这些问题产生了重大影响.这里是更正后的版本(这里是工作jsfiddle的链接):
$('#msform').validate({
rules: {
videoFile: {
required: true,
extension:'mov|mp4|mpeg|wmv'
}, //notice the comma I added
videoTitle: {
required: true,
}, //notice the comma I added
videoDescription: {
required: true,
}
},
messages: {
videoFile: "Please specify a file", //notice the comma I added
videoTitle: "Title is required", //notice the comma I added
videoDescription: "Description is required"
}
});
if ((!$('#msform').valid())) { //I added an extra parenthesis at the end
return false;
}
Run Code Online (Sandbox Code Playgroud)
大多数主流浏览器现在都有开发人员控制台的选项.
在Firefox中,您可以下载Firebug.我在看着你的jsfiddle时打开了Firebug,它立刻向我展示了所有的语法错误.这就是我纠正上述代码的方式.
谷歌浏览器在View - > Developer - > JavaScript Console下也有一个控制台
请记住,对象中的成员必须用逗号分隔.这就是导致大多数语法问题的原因.
| 归档时间: |
|
| 查看次数: |
9288 次 |
| 最近记录: |