validate: function()

in server/resources/js/ResourceDialog.js [149:188]


  validate: function () {
    var errorsPresent = false;
    this.clearErrors();
    var flag = $j('#resource_type option:selected').val();
    if (flag === 'custom') {
      var val = $j.trim($j('#customValues').val());
      if (val === '') {
        BS.Util.show('error_Values');
        $j('#error_Values').html("Please define custom values for resource");
        errorsPresent = true;
      }
    } else if (flag === 'quoted') {
      var val = $j.trim($j('#resource_quota').val());
      if (val.length === 0) {
        BS.Util.show('error_Quota');
        $j('#error_Quota').html("Value must not be empty");
        errorsPresent = true;
      }
      if (!/^[0-9]+$/.test(val)) {
        BS.Util.show('error_Quota');
        var message = "Value " + val + " is not correct";
        $j('#error_Quota').html(message.escapeHTML());
        errorsPresent = true;
      }
    }

    var element = $j('#resource_name');
    var value = $j.trim(element.val());
    if (value.length === 0) { // check not empty
      BS.Util.show('error_Name');
      $j('#error_Name').html("Name must not be empty");
      errorsPresent = true;
    } else if (!/^[A-Za-z0-9_]+$/.test(value)) {
      BS.Util.show('error_Name');
      $j('#error_Name').html("The name is invalid. It should start with a latin letter and contain only latin letters, digits and underscores (80 characters max).");
      errorsPresent = true;
    }
    element.val(value);
    return !errorsPresent;
  },