I want to check the type of the downloaded file using the validate plugin.
But I got the following error message:
Uncaught TypeError: Cannot read property 'call' of undefined. Exception occurred when checking element file, check the 'accept' method.
Here is my form.
<form id="upload" enctype="multipart/form-data"> <div class="control-group"> <div class="controls"> <input id="file" name="file" type="file"> </div> <div class="form-group"> <button class="btn btn-primary" onclick="Submit()" type="button">Submit</button> </div> </div> </form>
And here is my JavaScript:
var Submit=function(){ var validator = $('#upload').validate({ rules:{ file: { required: true, accept: "audio/*, video/*" } }, message: { file:"Invalid file type" } }); validator.form(); }
source share