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

database.js / file controller : add a client side form validator for file...

database.js / file controller : add a client side form validator for file upload (check the number of file provided/pre_process)
parent c50cccde
......@@ -257,7 +257,7 @@ Database.prototype = {
for (var i=0; i<field.options.length; i++){
var option = field.options[i];
if (value == option.value){
if (option.getAttribute("data-file") == "1"){
if (option.getAttribute("required_files") == "1"){
document.getElementById("file2_field").style.display = 'none';
document.getElementById("upload_file2").value=""
}else{
......@@ -995,6 +995,21 @@ Database.prototype = {
tgt.empty();
$('body').css('cursor', 'default');
},
validate_fileform: function (form) {
var pp_option = document.getElementById("pre_process").getElementsByTagName("option");
var pp = form.pre_process.value
var required_files = 1;
for (var i in pp_option){
if (pp == pp_option[i].value){
required_files = pp.option[i].getAttribute("required_files");
}
}
return false;
},
// Log functions, to server
// 'quiet' is set to true to avoid infinite loops with timeouts
......
......@@ -3,7 +3,7 @@
<h3>New sequence file</h3>
<div>
<form id="upload_form" action="DB_ADDRESS/file/add_form" enctype="multipart/form-data" method="post">
<form id="upload_form" onsubmit="return db.validate_fileform(this)" action="DB_ADDRESS/file/add_form" enctype="multipart/form-data" method="post">
<input type="hidden" id="filename" name="filename" type="text" value="">
<input type="hidden" id="sample_type" name="sample_type" value="{{=sample_type}}" />
<table>
......@@ -12,9 +12,9 @@
<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"]}}">
<option title="{{=row["info"]}}" required_files="{{=row["file"]}}" value="{{=row["id"]}}">
{{=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