Announcing the Global SNUG Board of Directors. Learn more here
on 06-18-2020 08:04 PM
Script created to validate the number entered, from 1 (one character) to 100000000000 (twelve characters)
Below is a CLIENT SCRIPT using REGEX to validate a STRING type field, allowing only INTEGER NUMERIC to be inserted, without "." (dot) and "," as for LETTERS,
it will not be necessary, as the INTEGER field type itself already changes the value entered in LETTERS for "0":
Follow the steps below:
Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
//Variable created containing the regex that validates if the value entered is WHOLE NUMBER ONLY
var regExTest = /(^[0-9]*$)|(^[0-9]+,[0-9]*$)|(^[0-9]+,[0-9]+,[0-9]*$)|(^[0-9]+,[0-9]+,[0-9]+,[0-9]*$)/;
//Validation condition using the REGEX variable.
if ((newValue == 0) || (!regExTest.test(newValue))) {
alert(''Please enter only Numbers. For Example: (1 or 1000 or 1000000) - Without "." and either ","!'); //Enter THERE the MESSAGE to ALERT that you would like the USER to receive when typing wrong.
g_form.setValue('u_test_integer', ''); //Insert your field to be cleared after the ALERT confirmation.
}
}
Obs.:
If your field is not inserted in the form automatically, insert it manually following the steps below:
1 - Expand a record of your table:
2 - Click on the Burguer located in the upper left corner:
3 - Then click on "CONFIGURE" and "FORM LAYOUT":
4 - Choose the POSITION you want to insert it and Transfer the FIELD "TEST INTEGER" in the LEFT list to the RIGHT list by clicking on the ">" ARROW located in the center of the screen:
Tests:
Create a new record in your table and insert the characters in the field to be validated:
Test 1: Insert only TEXT and press TAB:
Test 2: Click in OK and Insert two or more numbers separated by dot (.) And press TAB:
Test 3: Click in OK and Insert FOUR or MORE numbers and hit TAB (Allow value inserted with four characters):
Thanks for sharing this!!!