Varování při poslání prázdného řešení
This commit is contained in:
parent
0c176b8a91
commit
1a31a5b034
1 changed files with 21 additions and 1 deletions
|
@ -10,7 +10,7 @@
|
|||
Vložit řešení
|
||||
{% endblock %}{% endblock %}
|
||||
</h1>
|
||||
<form enctype="multipart/form-data" action="{% url 'seminar_nahraj_reseni' %}" method="post">
|
||||
<form enctype="multipart/form-data" action="{% url 'seminar_nahraj_reseni' %}" method="post" onsubmit="return zkontroluj_prilohy();">
|
||||
{% csrf_token %}
|
||||
<table class='form' id="reseni">
|
||||
<tr>
|
||||
|
@ -106,4 +106,24 @@
|
|||
<input type="submit" value="Odevzdat">
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
function zkontroluj_prilohy() {
|
||||
var soucet = 0;
|
||||
var formulare = document.getElementById("form_set").children;
|
||||
for (var formular of formulare) {
|
||||
var upload = formular.getElementsByTagName("input")[0];
|
||||
soucet += upload.files.length;
|
||||
}
|
||||
if (soucet == 0) {
|
||||
var vysledek = confirm("Nepřiložil jsi žádný soubor. Přesto odeslat?");
|
||||
if (!vysledek) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in a new issue