aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/static/new/javascript/validation.coffee19
-rw-r--r--wqflask/wqflask/templates/show_trait.html6
2 files changed, 16 insertions, 9 deletions
diff --git a/wqflask/wqflask/static/new/javascript/validation.coffee b/wqflask/wqflask/static/new/javascript/validation.coffee
index f389254e..a2036c1d 100644
--- a/wqflask/wqflask/static/new/javascript/validation.coffee
+++ b/wqflask/wqflask/static/new/javascript/validation.coffee
@@ -1,19 +1,26 @@
$ ->
remove_samples_is_valid = (input)->
- return $.isNumeric(input)
-
- #invalidate_block_by_index = ->
- # $('#remove_samples_invalid').show()
-
+ splats = input.split(",")
+ new_splats = (_.trim(input) for input in splats)
+ console.log("new_splats:", new_splats)
+ pattern = /^\d+\s*(?:-\s*\d+)?\s*$/
+ for splat in new_splats
+ console.log("splat is:", splat)
+ if not splat.match(pattern)
+ return false
+ return true
+
+
validate_remove_samples = ->
input = $('#remove_samples_field').val()
console.log("input is:", input)
- $('#remove_samples_invalid').hide()
if remove_samples_is_valid(input)
console.log("input is valid")
+ $('#remove_samples_invalid').hide()
else
console.log("input isn't valid")
$('#remove_samples_invalid').show()
+
$('#remove_samples_field').change(validate_remove_samples) \ No newline at end of file
diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html
index 5937b60b..a20017da 100644
--- a/wqflask/wqflask/templates/show_trait.html
+++ b/wqflask/wqflask/templates/show_trait.html
@@ -1232,9 +1232,9 @@
</select>
<input type="button" id="block_by_index" class="btn" value="Block">
</div>
- <div id="remove_samples_invalid" style="display:none;">
- Please check that your input is formatted correctly
- </div>
+ <div id="remove_samples_invalid" class="alert alert-error" style="display:none;">
+ Please check that your input is formatted correctly, e.g. <strong>3, 5-10, 12</strong>
+ </div>
<br>