Number

Checking Number Range

Most of the values entered through the input form are processed as text. The system does not know if the entered value is a number or a date. Even if the user enters a number, in order to compare or process it, it is sometimes necessary to specify that it is a number.

Example

Return true if there is a desired value (INPUT) between the two input values (FROM, TO), otherwise, return false.

sample_number_01.xfdl

Core features used in the example

Number

This is used to create the Number object or convert it to the numeric type. The help does not recommend explicitly creating the Number object using the new operator. In the example, it is used for the type conversion of the numeric value transmitted as the character string.

How to implement an example

1

Configuring Form Screen

Place the Static component, Edit component, and Button component.

2

Writing Button Component Click Event Function

Write the event function to be executed when the Button component is clicked. Verify the input value in the fn_isNumArea function and display the verified result in the Edit component.

this.Button00_onclick = function(obj:nexacro.Button,e:nexacro.ClickEventInfo)
{
    var nRtn = this.fn_isNumArea(this.Edit02.value, this.Edit00.value, this.Edit01.value);
    this.Edit03.value = nRtn;
};

3

Writing fn_isNumArea Function

Receive the entered character and convert it to the number (Number). The converted numeric value is compared to determine the return value.

this.fn_isNumArea = function(sValue, sArea1, sArea2)
{   
    var nValue = Number(sValue);
    var nArea1 = Number(sArea1);
    var nArea2 = Number(sArea2);
    
    if (nArea1 > nArea2) 
    {
        return false;
    }
    
    if (nValue >= nArea1 && nValue <= nArea2) 
    {
        return true;
    } 
    else 
    {
        return false;        
    }
}

If the value to be used is the integer, then the same function can be processed by using parseInt. The first script of the fn_isNumArea function can be changed as follows.

this.fn_isNumArea = function(sValue, sArea1, sArea2)
{   
    var nValue = parseInt(sValue);
    var nArea1 = parseInt(sArea1);
    var nArea2 = parseInt(sArea2);
	...

4

Checking with QuickView

Run it with QuickView (Ctrl + F6) and enter the value to check.