Commit 39010850 authored by marc's avatar marc Committed by Mathieu Giraud
Browse files

database.js : validate_form for upload file

parent 17ab708c
......@@ -997,18 +997,22 @@ Database.prototype = {
},
validate_fileform: function (form) {
var pp_option = document.getElementById("pre_process").getElementsByTagName("option");
var pp_option = form.pre_process.getElementsByTagName("option");
var pp = form.pre_process.value
var required_files = 1;
for (var i in pp_option){
for (var i=0; i<pp_option.length; i++){
if (pp == pp_option[i].value){
required_files = pp.option[i].getAttribute("required_files");
required_files = pp_option[i].getAttribute("required_files");
}
}
return false;
if (required_files == 2 && document.getElementById("upload_file2").value ==""){
console.log({"type": "flash", "msg" : "2 files are required for the selected pre-process", "priority": 2});
return false
}
return true;
},
// Log functions, to server
......
......@@ -7,7 +7,7 @@ info = db.sequence_file[request.vars["id"]]
<h3>Edit sequence file</h3>
<form id="upload_form" action="DB_ADDRESS/file/edit_form" enctype="multipart/form-data" method="post">
<form id="upload_form" action="DB_ADDRESS/file/edit_form" enctype="multipart/form-data" method="post">
<input type="hidden" id="filename" name="filename" type="text" value="">
<input type="hidden" id="file_id" name="id" value="{{=request.vars["id"]}}" >
<input type="hidden" id="sample_type" name="sample_type" value="{{=sample_type}}" />
......@@ -17,9 +17,9 @@ info = db.sequence_file[request.vars["id"]]
<tr>
<td><label for="pre_process" id="pre_process__label">pre-process scenario: </label></td>
<td><select id="pre_process" name="pre_process" onChange="db.pre_process_onChange()">
<option data-file="1" value="0">no pre-process (1 file)</option>
<option required_files="1" value="0">no pre-process (1 file)</option>
{{for row in pre_process_list :}}
<option title="{{=row["info"]}}" data-file="{{=row["file"]}}" value="{{=row["id"]}}" {{if row["id"]==file.pre_process_id :}}selected{{pass}}>
<option title="{{=row["info"]}}" required_files="{{=row["file"]}}" value="{{=row["id"]}}" {{if row["id"]==file.pre_process_id :}}selected{{pass}}>
{{=row["id"]}} &ndash; {{=row["name"]}}
</option> {{pass}}
</select>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment