Using JQuery I am restricting the file extension but I am getting an issue is that "If I don't upload any video just I am clicking the upload button its not validating". This is my code, what editing I have to do?
Sample.aspx
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
$(function () {
$('#<%=FileUploadbtn.ClientID %>').change(
function () {
var fileExtension = ['mp4'];
if ($.inArray($(this).val().split('.').pop().toLowerCase(), fileExtension) == -1) {
// alert("Invalid");
$('#<%=uploadbtn.ClientID %>').attr("disabled", true);
$('#<%= lblError.ClientID %>').html("Invalid");
}
else {
$('#<%=uploadbtn.ClientID %>').attr("disabled", false);
$('#<%= lblError.ClientID %>').html(" ");
}
})
})
ASPX Code
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Upload" CssClass="button" OnClick="uploadbtn_Click" />
<asp:Label ID="lblError" runat="server" Text="Label"></asp:Label>
Aucun commentaire:
Enregistrer un commentaire