Skip to main content
Solved

In FSM Mobile validation for Alpha Numeric data in a field

  • May 10, 2024
  • 1 reply
  • 59 views

Forum|alt.badge.img+2

Hi All,

In FSM mobile can we check if in the field user is adding an alphanumeric value and trying to save to thrown an exception to add only numeric data. Is it possible using client script.

 

Thanks,

Lavanya

 

Best answer by shalikakk

@B Lavanya You can use the following script to check whether the input values are numeric or not.

 

var inputValue = getControlValue("custom",”barcode”);
var vLength = getDBValues(stringFormat("SELECT LENGTH('{0}') AS len FROM task WHERE task_id = (SELECT MIN(task_id) FROM task)", inputValue));
var j = "";
var x = "";

for (var i = 1; i <= vLength[0]["len"]; i++)
{
    j = getDBValues(stringFormat("SELECT SUBSTRING('{0}', {1}, 1) AS char FROM task LIMIT 1", getFromCache("isNumeric"), i ));
    x = "a" + j[0]["char"];
if (x != "a0" && x != "a1" && x != "a2" && x != "a3" && x != "a4" &&
        x != "a5" && x != "a6" && x != "a7" && x != "a8" && x != "a9" && 
        x != "a." )
        {
return "0";
        }
}
return "1";


You can run the above script using the executeScript function. It returns 1 if the input is a numeric value. Otherwise it returns 0.

Thanks.

View original
Did this topic help you find an answer to your question?

shalikakk
Hero (Employee)
Forum|alt.badge.img+7
  • Hero (Employee)
  • May 10, 2024

@B Lavanya You can use the following script to check whether the input values are numeric or not.

 

var inputValue = getControlValue("custom",”barcode”);
var vLength = getDBValues(stringFormat("SELECT LENGTH('{0}') AS len FROM task WHERE task_id = (SELECT MIN(task_id) FROM task)", inputValue));
var j = "";
var x = "";

for (var i = 1; i <= vLength[0]["len"]; i++)
{
    j = getDBValues(stringFormat("SELECT SUBSTRING('{0}', {1}, 1) AS char FROM task LIMIT 1", getFromCache("isNumeric"), i ));
    x = "a" + j[0]["char"];
if (x != "a0" && x != "a1" && x != "a2" && x != "a3" && x != "a4" &&
        x != "a5" && x != "a6" && x != "a7" && x != "a8" && x != "a9" && 
        x != "a." )
        {
return "0";
        }
}
return "1";


You can run the above script using the executeScript function. It returns 1 if the input is a numeric value. Otherwise it returns 0.

Thanks.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings