aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask/static/new/javascript/validation.js
blob: 2cacacfa0077350cc4546cbb6401dcc5891c2a48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Generated by CoffeeScript 1.8.0
$(function() {
  var remove_samples_is_valid, validate_remove_samples;
  remove_samples_is_valid = function(input) {
    var new_splats, pattern, splat, splats, _i, _len;
    if (_.trim(input).length === 0) {
      return true;
    }
    splats = input.split(",");
    new_splats = (function() {
      var _i, _len, _results;
      _results = [];
      for (_i = 0, _len = splats.length; _i < _len; _i++) {
        input = splats[_i];
        _results.push(_.trim(input));
      }
      return _results;
    })();
    pattern = /^\d+\s*(?:-\s*\d+)?\s*$/;
    for (_i = 0, _len = new_splats.length; _i < _len; _i++) {
      splat = new_splats[_i];
      if (!splat.match(pattern)) {
        return false;
      }
    }
    return true;
  };
  validate_remove_samples = function() {

    /*
    Check if input for the remove samples function is valid and notify the user if not
     */
    var input;
    input = $('#remove_samples_field').val();
    if (remove_samples_is_valid(input)) {
      return $('#remove_samples_invalid').hide();
    } else {
      return $('#remove_samples_invalid').show();
    }
  };
  return $('#remove_samples_field').change(validate_remove_samples);
});