Merge pull request #2407 from mlorb/ml-sci-4329

Fix adding too small/big number to input... [SCI-4329]
This commit is contained in:
mlorb 2020-02-14 10:40:20 +01:00 committed by GitHub
commit 618aa698d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -196,6 +196,14 @@ function filesSizeValidator(ev, fileInputs, fileTypeEnum) {
return filesSizeValid; return filesSizeValid;
} }
function numberMinMaxValidator(value, min, max) {
if(parseInt(value) < min || isNaN(value))
return min;
else if(parseInt(value) > max)
return max;
else return value;
}
/* /*
* Overriden in billing module for checking whether enough * Overriden in billing module for checking whether enough
* team space is free. * team space is free.

View file

@ -5,7 +5,8 @@
<%= t('libraries.manange_modal_column.number_type.decimals_label') %> <%= t('libraries.manange_modal_column.number_type.decimals_label') %>
</label> </label>
<div class="col-sm-3"> <div class="col-sm-3">
<%= number_field_tag('decimals', selected_decimals, in: 0...Constants::REPOSITORY_NUMBER_TYPE_MAX_DECIMALS, <%= number_field_tag('decimals', selected_decimals, between: 0...Constants::REPOSITORY_NUMBER_TYPE_MAX_DECIMALS,
class: 'form-control') %> class: 'form-control',
oninput: "this.value = numberMinMaxValidator(this.value, 0, #{Constants::REPOSITORY_NUMBER_TYPE_MAX_DECIMALS})" ) %>
</div> </div>
</div> </div>