Hi all,
I have a problem retrieving some values from inputs. Specifically, Input element with the content format set as “Currency”. I tried inspecting the element DOM properties and its showing:
value: Getter & Setter
valueAsDate: null
valueAsNumber: NaN
It works fine only when the input is a normal integer type. I’m trying to retrieve the value into a variable using:
if (document.getElementById(“myIncome”) && document.getElementById(“myIncome”).value) {
var myIncome = document.getElementById(“myIncome”).value;
}
Note: I did manually set the ID to the input field to use a specific ID via the app settings.
Does anyone have any idea how to go about extracting only the value of the currency input? The currency input has a currency prefix to it which is what I’m suspecting is the difference from a normal integer field.
P/S: I am using the above approach to extract the value from the field to run a long list of complex calculations which I have written in a custom javascript function contained in an HTML block.
–
[ISSUE] Confirmed that it was due to the input type set as currency.
[SOLUTION] After getting the value, i added replace(/[^0-9.]/g, “”) to convert it back to a number.
document.getElementById(“myIncome”).value.replace(/[^0-9.]/g, “”)