I have the following function:
function formatNumber(num) {
return “$” + num
.toFixed(2)
.replace(/(\d)(?=(\d{3})+(?!\d))/g, “$1,”);
}
export function input2_change(event) {
$w(‘#input2’).value = formatNumber(Number($w(‘#input2’).value));}
The code is only for entering numbers and signs, and that the numbers are automatically aligned for example $1, but I would like that when letters are entered, the field is automatically deleted.
With this code, when you enter letters in the text field instead of deleting it, NaN appears and the field is not deleted.