From 1c5931ad6696d99941cca1edd22c0622373cac48 Mon Sep 17 00:00:00 2001 From: NotWearingPants <26556598+NotWearingPants@users.noreply.github.com> Date: Sat, 23 Oct 2021 21:56:25 +0300 Subject: [PATCH] fix(form): fetch range input prompt for numeric values only The check in the prompt assumed the rule value is a string, but it may also be a regex, which throws an exception. Additionally, it can be a normal string with two dots, e.g. type: "contains[hello..world]" which shouldn't be treated as a range. So I changed the check to also verify the type can contain a range, rather than just check if the value has two dots inside. Given the rule { type: 'contains[hello...]' } the resulting prompt is Please enter a valid value and must be in a range from hello to . which is nonsense, since it checks whether the text contains the literal hello.... Given the rule { type: 'regExp', value: /hello/ } we get an exception Uncaught TypeError: ancillary.indexOf is not a function because ancillary is a RegExp and not a string, so doesn't have indexOf. Validation is then entirely broken. --- src/definitions/behaviors/form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/definitions/behaviors/form.js b/src/definitions/behaviors/form.js index a989a58f99..b39f05643c 100644 --- a/src/definitions/behaviors/form.js +++ b/src/definitions/behaviors/form.js @@ -544,7 +544,7 @@ $.fn.form = function(parameters) { parts, suffixPrompt ; - if(ancillary && ancillary.indexOf('..') >= 0) { + if(ancillary && ['integer', 'decimal', 'number'].indexOf(ruleName) >= 0 && ancillary.indexOf('..') >= 0) { parts = ancillary.split('..', 2); if(!rule.prompt) { suffixPrompt = (