0

I'm trying to change the on alert function to make it just proceed so as to save user's time, as no additional button is needed to be pressed in order to proceed for the uploading of files, and alert is just a mere notice for users such that their files are successfully uploaded.

Codes in HTML

<form method="post" enctype="multipart/form-data" onsubmit="myFunction()"> {% csrf_token %}
   <input name="input_file" type="file" id="input_file"/>
</form>

<script>
   function myFunction() {
   alert("The files have been successfully submitted");
   }
</script>

Can anyone show me the solution to this recurring problem of mine? And also, I'm using jquery too. Thank you.

  • 5
    That isn't possible using a standard `alert(...)`. You'll need to create your own popup/modal. You could use a jQuery one if you wanted to, though personally I'd recommend [SweetAlert2](https://sweetalert2.github.io/). One of the examples (#10 or so) is an alert with an auto-close timer. – Tyler Roper Jul 16 '19 at 00:59
  • 1
    don't use `alert` pretty much ever – Sampson Crowley Jul 16 '19 at 01:01
  • as @TylerRoper mentioned, SweetAlert is a really well built modal library – Sampson Crowley Jul 16 '19 at 01:02
  • 1
    Possible duplicate of [How can I auto hide alert box after it showing it?](https://stackoverflow.com/questions/15466802/how-can-i-auto-hide-alert-box-after-it-showing-it) – Sampson Crowley Jul 16 '19 at 01:04
  • Okay! Thank all of you so much for all your help :) – reallyneedhelp Jul 16 '19 at 06:17

0 Answers0