必需如果数据注释在文件上传的客户端不起作用

requiredif data annotation does not work client side with file uploads

提问人:Tom W 提问时间:11/8/2023 最后编辑:Tom W 更新时间:11/9/2023 访问量:22

问:

我正在使用 expressive.annotations.validate.js 在客户端进行验证,但它不适用于文件上传,特别是 requiredif 文件。

我使用 requiredif 表示除非选中复选框,否则文件上传是必需的,但强制要求客户端。

我希望在客户端强制执行所需的内容,除非选中该复选框。

这是我正在使用的代码:

公共布尔?IsEligible { get; set;

    [Display(Name = "Choose Files")]
    [RequiredIf("IsEligible", true, ErrorMessage = "Documentation is required. Supported File Formats: PDF, PNG, JPG, and JPEG, of size under 5 MB.")]
    [NotMapped]
    [DataType(DataType.Upload)]
    [FileType("PDF,JPG,JPEG,PNG,pdf,jpg,jpeg,png", ErrorMessage = "Please select only Supported Files PDF, PNG, JPG, and JPEG, of size under 5 MB.")]
    [FileSize(5000000, ErrorMessage = "Please select a file under 5 MB")]
    public List<HttpPostedFileBase> DocumentationFiles { get; set; }
JavaScript C# 验证

评论

0赞 Jayanika Chandrapriya 11/8/2023
请提供足够的代码,以便其他人可以更好地理解或重现问题。

答: 暂无答案