From f8c6bec2a61c53862edc7cd1eb42dca4eb854c40 Mon Sep 17 00:00:00 2001 From: spnegi <150329891+spnegi@users.noreply.github.com> Date: Wed, 8 Oct 2025 21:27:03 +0530 Subject: [PATCH 1/2] Create Allow positive and decimal values.js --- .../Allow positive and decimal values.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Allow positive and decimal values/Allow positive and decimal values.js diff --git a/Client-Side Components/Client Scripts/Allow positive and decimal values/Allow positive and decimal values.js b/Client-Side Components/Client Scripts/Allow positive and decimal values/Allow positive and decimal values.js new file mode 100644 index 0000000000..435b3245a5 --- /dev/null +++ b/Client-Side Components/Client Scripts/Allow positive and decimal values/Allow positive and decimal values.js @@ -0,0 +1,13 @@ +function onChange(control, oldValue, newValue, isLoading) { + if (isLoading || newValue == '') { + return; + } + + var regex = /^[0-9]+(\.\d{1,2})?$/; // Allows positive integers or decimals + + if (!regex.test(newValue) || newValue <= 0) { + g_form.setValue('amount', ''); + g_form.showFieldMsg('amount', 'Please enter a amount greater than zero with decimals .Decimals are allowed here.', 'error'); + + } +} From 13874207a6ec0877f43d30f04b80970e266deb85 Mon Sep 17 00:00:00 2001 From: spnegi <150329891+spnegi@users.noreply.github.com> Date: Wed, 8 Oct 2025 21:29:10 +0530 Subject: [PATCH 2/2] Create readme.md --- .../Allow positive and decimal values/readme.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Allow positive and decimal values/readme.md diff --git a/Client-Side Components/Client Scripts/Allow positive and decimal values/readme.md b/Client-Side Components/Client Scripts/Allow positive and decimal values/readme.md new file mode 100644 index 0000000000..1fbdd451c1 --- /dev/null +++ b/Client-Side Components/Client Scripts/Allow positive and decimal values/readme.md @@ -0,0 +1,7 @@ +Purpose of this script: + +It matches positive numbers (integers or decimals) +It does not match 0 or 0.0 (i.e., it excludes non-positive numbers). + +So this regex is used when you want to allow only positive (> 0) integer or decimal values. +It will give us the field message error if anyone tries to enter anything apart from the allowed values