aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsloan2022-01-26 20:54:03 +0000
committerzsloan2022-01-27 13:45:09 -0600
commite5f179330b024671e066edb0672a5a8b628766ed (patch)
treea1129798c302be9cf94e2d3e1233651a3164dc75
parent480d71d9e12878449f7526cacb644f686a9169af (diff)
downloadgenenetwork2-e5f179330b024671e066edb0672a5a8b628766ed.tar.gz
Replaced the try/catch with something checking for the correct pattern with regex, for validating the Select Rows input
-rw-r--r--wqflask/wqflask/static/new/javascript/search_results.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/wqflask/wqflask/static/new/javascript/search_results.js b/wqflask/wqflask/static/new/javascript/search_results.js
index b7ad359f..a3e21081 100644
--- a/wqflask/wqflask/static/new/javascript/search_results.js
+++ b/wqflask/wqflask/static/new/javascript/search_results.js
@@ -102,11 +102,17 @@ $(function() {
*/
parseIndexString = function(idx_string) {
index_list = [];
+
_ref = idx_string.split(",");
for (_i = 0; _i < _ref.length; _i++) {
index_set = _ref[_i];
+ if (!/^ *([0-9]+$) *| *([0-9]+ *- *[0-9]+$) *|(^$)$/.test(index_set)) {
+ $('#select_samples_invalid').show();
+ break
+ } else {
+ $('#select_samples_invalid').hide();
+ }
if (index_set.indexOf('-') !== -1) {
- try {
start_index = parseInt(index_set.split("-")[0]);
end_index = parseInt(index_set.split("-")[1]);
@@ -118,10 +124,6 @@ $(function() {
for (index = start_index; index <= end_index; index++) {
index_list.push(index);
}
- } catch (_error) {
- error = _error;
- alert("Syntax error");
- }
} else {
index = parseInt(index_set);
index_list.push(index);