Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

// Regex: allows positive integers or decimals with up to two decimal places
var regex = /^[0-9]+(\.\d{1,2})?$/;

// Regex explanation:
// ^ : Start of string
// [0-9]+ : One or more digits (whole number part)
// (\.\d{1,2})? : Optional decimal part
// \. : Literal decimal point
// \d{1,2} : One or two digits after the decimal
// $ : End of string
// This pattern matches positive integers or decimals with up to two decimal places

// Replace 'amount' with the actual field name this script is attached to
var fieldName = "amount";

if (!regex.test(newValue) || newValue <= 0) {
g_form.clearValue(fieldName);
g_form.showFieldMsg(fieldName, 'Please enter a value greater than zero. Decimals are allowed (up to two places).', 'error');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Numeric Field Validation Script

This script validates numeric input in a form. It is used to ensure that values entered in fields like amount or price are properly formatted.

### Validation Rules

- Only positive numbers are allowed
- Decimals are allowed, up to two digits
- Zero or negative values are not accepted
- Invalid input will clear the field and show an error message
Loading