Logo Questions Linux Laravel Mysql Ubuntu Git Menu

jQuery media validation by content type

I would like to validate video files with content type. This is possible for audios Link here. I don't want to validate by mentioning the extensions. But I want to validate whether the file is video file or not?? Is it possible?? or I really need to mention extension for validation.

like image 872
Sam Avatar asked Nov 28 '13 11:11


2 Answers

According to Wikipedia all MIME types for videos begin with video/*.

So you simply need to change audio/* to video/*:

$( "#myform" ).validate({
    rules: {
        field: {
            required: true,
            accept: "video/*"

Please check working example.

like image 180
n1ckolas Avatar answered Oct 14 '22 18:10


What about using HTML5 ? ...

<input type="file" name="video" accept="video/*">
<input type="file" name="audio" accept="audio/*">
<input type="file" name="video_audio" accept="video/*, audio/*">

for modern browsers

Doc : Input#attr-accept

so do fallback as @n1ckolas's answer

like image 26
l2aelba Avatar answered Oct 14 '22 18:10