0

So I've got an HTML form with an upload.

<input type="file" name="uploaded_file" id="uploaded_file">

Using jQuery I am doing a client side size check of the file.

jQuery('#uploaded_file').bind('change', function() {
var size = this.files[0].size/1024/1024;

if (size > 3.00){
jQuery("#upload_msg").html('File size is ' + size.toFixed(2) + ' / 3.00 MB.');
}

if (size <= 3.00){
jQuery("#upload_msg").html('File size is ' + size.toFixed(2) + ' / 3.00 MB.');
}});

I want to set a condition so that if a user chooses a file, then changes their mind and unchooses a file to upload that the jQuery adjust back to it's original form.

How do I set a condition for that? Thank you!

1 Answer 1

1

You need to check value with val() method of input tag and if it contains filename you should go with your logic otherwise skip your logic.

Sign up to request clarification or add additional context in comments.

1 Comment

I will see what I can do. I'm pretty new to jQuery because I avoided it as long as possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.