From f10e832037fabc718eb24d12c01c6dacd77967b7 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Wed, 10 Oct 2012 17:25:50 -0500 Subject: Got the validation code for remove samples by index mostly working --- .../wqflask/static/new/javascript/validation.coffee | 19 +++++++++++++------ wqflask/wqflask/templates/show_trait.html | 6 +++--- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'wqflask') 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 @@ -
+