Client validation of INPUT of type FILE without postback using jQuery

Posted by Fixer on Stack Overflow See other posts from Stack Overflow or by Fixer
Published on 2011-01-02T05:36:16Z Indexed on 2011/01/02 5:54 UTC
Read the original article Hit count: 214

I want to check on the client side that a file has been selected before the form can be submitted.

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm("Upload", "Files", FormMethod.Post, new { enctype = "multipart/form-data" }))
        { 
            <input id="File" name="File" type="file" size="80" />
            <input type="submit" name="name" value="Upload" />    
        }

Currently this form is doing postbacks for validation. What is going wrong?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about jQuery