4

Once the user chooses the file, I have a condition using html5 file api to check if the file size exceeds a 1mb.

function handleLimit(evt) {
   var files = evt.target.files; 
   f = files[0];
   console.log(f.size);
   if (f.size > 1048576) {
          /*JS for clearing form*/
   }
}

What would be the script I would want to run on my input tag to clear/ force the client to choose another file it once the handler knows that file is exceeding a certain size?

1

1 Answer 1

10
 var _fileuploadcontrolId = document.getElementById("id");
            _fileuploadcontrolId.value = "";
            _fileuploadcontrolId.focus();
Sign up to request clarification or add additional context in comments.

2 Comments

Perfect. I like your use of focus() for UX.
@Emanegux i dont know why some people behave like this.With out any comment giving downvote

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.