i am using http://bojanmauser.from.hr/bvalidator/ this script to validate my form, now i am stack with a problem, want to set max file limit for image file upload. but i am unsuccessful everytime, can anybody help me to get rid of this, advance thanx to all, who is reading this discussion and give a helping a hand to solve this problem...

Troy III commented: a correct answer has been given to you - you need to say "THANK YOU!" and mark your thread as "Solved!" -2

Recommended Answers

How do you set the max file limit? Why are you not successful? Any errors?

Jump to Post

You cannot use html() on the inputbox, try val()

Jump to Post

All 7 Replies

How do you set the max file limit? Why are you not successful? Any errors?

i dont know how to validate/limit the image file size using the bvalidator, thats why i am using a code to get the file size, here is the code

<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
<script language="javascript">
//Code Starts
$(document).ready(function() {
   $("#photo").change(function () 
   { 
     var iSize = ($("#photo")[0].files[0].size / 1024); 
     if (iSize / 1024 > 1) 
     { 
        if (((iSize / 1024) / 1024) > 1) 
        { 
            iSize = (Math.round(((iSize / 1024) / 1024) * 100) / 100);
            $("#photoSize").html( iSize ); 
        }
        else
        { 
            iSize = (Math.round((iSize / 1024) * 100) / 100)
            $("#photoSize").html( iSize ); 
        } 
     } 
     else 
     {
        iSize = (Math.round(iSize * 100) / 100)
        $("#photoSize").html( iSize ); 
     }    
  }); 
});

//Code Ends
</script>



Select file : <input type="file" id="photo" />
<br/><br/>
File Size is : <b><label id="photoSize" /></b>

i am trying to get the size in input box, then i will validate the value with bvalidator, but if i changed the label into a input box its not display the size, help me, what can i do at this situation?

You cannot use html() on the inputbox, try val()

thanx again for your reply, sorry, but i am not good at javascript, if you show me in code, then it will be better for me to understand.

Line 24.

i tried that but it dont display.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.