From 711536f53a2c20f51438c5a9080f0ace8dee7130 Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Fri, 23 Sep 2022 15:53:06 +0530 Subject: [PATCH] settings: Fix custom time limit input validation. Previously, typing something like "24aa" in message edit limit custom input box would not disable the "Save changes" button and clicking on it would set the limit to 24 minutes because "24aa" was parsed to 24 by parseInt which is a valid value. We now fix this to first convert the input to number using "Number()" function and then use parseInt. "Number()" function returns NaN for input like "24a" and other inputs containing alphabet characters and thus it is considered as invalid value and "Save changes" button is disabled. --- static/js/settings_org.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/settings_org.js b/static/js/settings_org.js index 9b89fdedae..48fb6dd9cf 100644 --- a/static/js/settings_org.js +++ b/static/js/settings_org.js @@ -896,7 +896,7 @@ function enable_or_disable_save_button($subsection_elem) { for (const setting_elem of time_limit_settings) { const dropdown_elem_val = $(setting_elem).find("select").val(); const custom_input_elem_val = Number.parseInt( - $(setting_elem).find(".admin-realm-time-limit-input").val(), + Number($(setting_elem).find(".admin-realm-time-limit-input").val()), 10, );