i got multiple input type file and i want to make a checking if the file max size exceeds the limit it clears the value of the input
file. if i use the id
if runs perfectly but when i change it to class
i got error like this
Uncaught ReferenceError: Invalid left-hand side in assignment
...
this is the script
<script src="https://code.jquery.com/jquery-2.1.4.min.js" ></script>
<input type="file" id="myFile2" class="upload" />
<input type="file" id="myFile1" class="upload" />
<input type="file" id="myFile3" class="upload" />
<script>
console.log("initiated");
var max_fileupload = 5899999;//5mb
$(".upload").bind('change', function(){
if(this.files[0].size > max_fileupload){
alert("attachment file size is greater than maximum file size required");
console.log($(this).val());
$(this).replaceWith( $(this).clone( true ) );
}
});
</script>
is this possible using the class of the input
file?