javascript - How to validate file input using Parsley JS? - Stack Overflow

I've used a custom validator to validate the file extension of a file input below. .addValidator(&

I've used a custom validator to validate the file extension of a file input below.

.addValidator('filetype', function(value, requirement) {
    return value.split('.').pop().toLowerCase() === requirement;
})

I'd really like to get access to the actual file so I can check the MIME type. Is there a way to get a reference back to the input so I can check the actual file date?

I've used a custom validator to validate the file extension of a file input below.

.addValidator('filetype', function(value, requirement) {
    return value.split('.').pop().toLowerCase() === requirement;
})

I'd really like to get access to the actual file so I can check the MIME type. Is there a way to get a reference back to the input so I can check the actual file date?

Share Improve this question asked Nov 3, 2015 at 23:58 tkiethanomtkiethanom 7172 gold badges8 silver badges21 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

Yes, the third argument is the parsley instance.

See this issue and this example

PRs for better documentation, as well as clean file validators in extra/ wele.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745174232a4615111.html

相关推荐

  • javascript - How to validate file input using Parsley JS? - Stack Overflow

    I've used a custom validator to validate the file extension of a file input below. .addValidator(&

    5小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信