I found this code some time ago in some blog, it is not mine, and I do not recall the author’s name, so I beg his/her pardon for not giving the credits, but I think this very interesting and simple for my friends from Brazil and Europe where they use commas instead of dots for decimal positioning.
This code will change a string like 1.234,56 into American format 1,234.56, very useful for converting an input value before inserting it into a database table.
<cfscript>
function validateSurface(str){
str = ReReplaceNoCase(str,'[^[:digit:],\,]','','all'); // this returns only digits and comma
str = replaceNoCase(str, ",", ".", "one"); // this replaces the first comma
// just in case there are more commas, crop the string.
if (find(str,",")){
str = left(str, find(str, ",") -1);
}
return str;
}
</cfscript>