我如何验证文件类型???。以下错误抛出异常“theFileElement is not found”
@using (Html.BeginForm("Index", "Data", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" name="FileUpload" />
<input type="submit" name="Submit" id="btnSubmit" value="Upload"/>
}
<script type="text/javascript">
$('#btnSubmit').click(function (e){
filename = theFileElement.value;
if (!/\.csv$/i.test(filename)) {
alert("Please upload csv file only");
return false;
}
return true;
});
</script>