admin管理员组文章数量:1355655
I am trying to validate a form with bootstrap validator, but the file validation is not going normal, here is my code:
cv: {
validators: {
file: {
extension: 'doc,docx,pdf,zip,rtf',
type: 'application/pdf,application/msword,application/rtf,application/zip',
maxSize: 5120 * 5120 * 5120 * 5120 * 5120, // 5 MB
message: 'The selected file is not valid, it should be (doc,docx,pdf,zip,rtf) and 5 MB at maximum.'
},
notEmpty: {
message: 'CV is required.'
}
}
},
the required files extensions are doc,docx,pdf,rtf,zip as shown above, but it only accept 3 extensions: doc,rtf,pdf...so where is the error in my code?
I am trying to validate a form with bootstrap validator, but the file validation is not going normal, here is my code:
cv: {
validators: {
file: {
extension: 'doc,docx,pdf,zip,rtf',
type: 'application/pdf,application/msword,application/rtf,application/zip',
maxSize: 5120 * 5120 * 5120 * 5120 * 5120, // 5 MB
message: 'The selected file is not valid, it should be (doc,docx,pdf,zip,rtf) and 5 MB at maximum.'
},
notEmpty: {
message: 'CV is required.'
}
}
},
the required files extensions are doc,docx,pdf,rtf,zip as shown above, but it only accept 3 extensions: doc,rtf,pdf...so where is the error in my code?
Share Improve this question edited Sep 14, 2016 at 11:56 Ish 2,1033 gold badges23 silver badges39 bronze badges asked Sep 4, 2014 at 9:11 MD.MDMD.MD 7184 gold badges14 silver badges36 bronze badges2 Answers
Reset to default 5You're missing the DOCX mime type :
application/vnd.openxmlformats-officedocument.wordprocessingml.document
So your code should look like :
file: {
extension: 'doc,docx,pdf,zip,rtf',
type: 'application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/rtf,application/zip',
maxSize: 5*1024*1024, // 5 MB
message: 'The selected file is not valid, it should be (doc,docx,pdf,zip,rtf) and 5 MB at maximum.'
},
See this fiddle example.
Here is simple example of file filed validation
http://formvalidation.io/validators/file/
本文标签:
版权声明:本文标题:javascript - how to validate files by bootstrap validator? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743958845a2568640.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论