diff --git a/app/assets/javascripts/sitewide/form_validators.js.erb b/app/assets/javascripts/sitewide/form_validators.js.erb index 54354084b..3b10c96d2 100644 --- a/app/assets/javascripts/sitewide/form_validators.js.erb +++ b/app/assets/javascripts/sitewide/form_validators.js.erb @@ -196,6 +196,14 @@ function filesSizeValidator(ev, fileInputs, fileTypeEnum) { 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 * team space is free. diff --git a/app/views/repository_columns/manage_column_partials/_number.html.erb b/app/views/repository_columns/manage_column_partials/_number.html.erb index 03ffa9b0f..2d4e59d2f 100644 --- a/app/views/repository_columns/manage_column_partials/_number.html.erb +++ b/app/views/repository_columns/manage_column_partials/_number.html.erb @@ -5,7 +5,8 @@ <%= t('libraries.manange_modal_column.number_type.decimals_label') %>
- <%= number_field_tag('decimals', selected_decimals, in: 0...Constants::REPOSITORY_NUMBER_TYPE_MAX_DECIMALS, - class: 'form-control') %> + <%= number_field_tag('decimals', selected_decimals, between: 0...Constants::REPOSITORY_NUMBER_TYPE_MAX_DECIMALS, + class: 'form-control', + oninput: "this.value = numberMinMaxValidator(this.value, 0, #{Constants::REPOSITORY_NUMBER_TYPE_MAX_DECIMALS})" ) %>