document.addEventListener('DOMContentLoaded', function() {
const input = document.getElementById('sales_price');
input.addEventListener('input', function(event) {
let value = event.target.value;
// Remove all characters except digits and decimal point
value = value.replace(/[^0-9.]/g, '');
// Check if there's a decimal point and split the number
const parts = value.split('.');
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
// Join the integer and decimal parts
value = parts.join('.');
// Add the dollar sign
if (value) {
value = '$' + value;
}
// Set the formatted value back to the input
event.target.value = value;
});
});