Jump to content

Remove the Currency Symbol from a String


Admin1676454018

Recommended Posts

Copy and paste everything below this line:

 

//

/********************************************************************************

DESCRIPTION: Removes currency or comma formatting from a source string.

 

PARAMETERS:

Field("income") is the variable needing Validation/conversion

strValue - Source string from which currency formatting

will be removed;

RETURNS:

Source string or Integer with commas removed

Resource("castle2.jpg") and other Resources can be returned based on value

*********************************************************************************/

//

 

 

var incomeInput = Trim(Field("income"));

//

function removeCurrency( strValue ) {

var objRegExp = /\(/;

var strMinus = '';

if(objRegExp.test(strValue)){

strMinus = '-';

} else {

objRegExp = /\)|\(|[,]/g;

strValue = strValue.replace(objRegExp,'');

if(strValue.indexOf('$') >= 0){

strValue = strValue.substring(1, strValue.length);

} else {

return strMinus + strValue;

}

}

}

//

//Strip decimals and call function

//Remove Int() function below to return number with decimals

//

var incomeValue = Int(removeCurrency(incomeInput));

//

//Change the Resources below to match what you need returned

//If statement switches images if Income is in certain range

//

if (incomeValue > "999999") {

if (incomeValue < "1999999"){

return Resource("castle2.jpg");

} else {

return Resource("castle3.jpg");

}

} else {

return Resource("castle1.jpg");

}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...