diff options
author | Zachary Sloan | 2012-10-10 17:25:50 -0500 |
---|---|---|
committer | Zachary Sloan | 2012-10-10 17:25:50 -0500 |
commit | f10e832037fabc718eb24d12c01c6dacd77967b7 (patch) | |
tree | 3517ebf8e48b0b97a48293eedc757b43ee01a658 /wqflask | |
parent | b3180cfd55917cac55f44147ea1e025714acd714 (diff) | |
download | genenetwork2-f10e832037fabc718eb24d12c01c6dacd77967b7.tar.gz |
Got the validation code for remove samples by index mostly working
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/static/new/javascript/validation.coffee | 19 | ||||
-rw-r--r-- | wqflask/wqflask/templates/show_trait.html | 6 |
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> |