JSP:
jquery.min.jsjquery.validate.min.jsadditional-methods.min.js<form role="form" class="form-horizontal" action="u.action" method="post" enctype="multipart/form-data"> <input type="file" name="file" class="form-control" id="file" accept=".csv" placeholder="Please select a csv file"> </form>
JS:
$('.form-horizontal').validate({ rules : { file : { required : true, extension: 'csv', accept : 'text/csv,text/comma-separated-value, application/vnd.ms-excel,application/vnd.msexcel,application/csv' } }, messages : { file : { required : "A csv file is required.", accept : "The file type must be 'CSV'." } }});