gpt4 book ai didi

javascript - 什么是多文件上传的js验证示例: name ="files[]"

转载 作者:行者123 更新时间:2023-12-01 01:05:54 30 4
gpt4 key购买 nike

这是 js 不工作,帮帮我

<input id="files" type="file" name="files[]" multiple/>

我的js是...

$("#GallaryForm").validate({

rules:
{
event_id:
{
required: true,
},
files:
{
required: true,
},



},
messages:
{
event_id:
{
required: 'Please Select Event .',

},
files:
{
required: 'Please Upload Image or Video.',
},

},
});

帮助我在文件上验证它不是工作中...

最佳答案

字段名称应使用单引号。

 'files[]':
{
required: true,
}

 'files[]':
{
required: 'Please Upload Image or Video.'
}

您的代码应该如下所示

$("#GallaryForm").validate({
rules: {
event_id: {
required: true, // <-- this comma is not required
},
'files[]': {
required: true, // <-- this comma is not required
}, // <-- this comma is not required
},
messages: {
event_id: {
required: 'Please Select Event .', // <-- this comma is not required
},
'files[]': {
required: 'Please Upload Image or Video.', // <-- this comma is not required
}, // <-- this comma is not required
}, // <-- this comma is not required
});

关于javascript - 什么是多文件上传的js验证示例: name ="files[]",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55650684/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com