c# - Java Script Validation for file uploading -


i got stuck in javascript validation in product adding form.

in page have file upload control upload product image. not getting how validate using javascript.

if image not uploaded control want display upload image message in label.

how accomplish this? please me.

the script have written is:

var fileup = document.getelementbyid('<%=fileuploadimg.clientid %>').value; if (fileup == "")  {    document.getelementbyid("lblfileuploadimg").innerhtml = "<font color='red'>    upload image file</font>";     document.getelementbyid('<%=fileuploadimg.clientid %>').focus();    return false; }  else  {     document.getelementbyid("lblfileuploadimg").innerhtml = ""; } 

the control have used is:

 <asp:fileupload id="fileuploadimg" runat="server" width="217px" height="20px" />  <asp:label id="lblfileuploadimg" runat="server" >  

with jquery this:

$('#myfile').bind('change', function() {     if(this.files[0].size>...){         alert('file big');     };  }); 

maybe looking for:

$("input:file").change(function () {     if ($(this).val() !== "") {         var ul_file = $(this).val();         var extension = ul_file.substr((ul_file.lastindexof('.') + 1));         var accepted_file_endings = ["jpg", "jpeg", "bmp", "gif", "tif", "png"];         extension = extension.tolowercase()         if ($.inarray(extension, accepted_file_endings) !== -1) {     ... 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -