jQuery(document).ready(function($) { $("#input_6_25").on("input", function() { // Get the input value var inputValue = $(this).val();
// Remove non-numeric characters except the dollar sign inputValue = inputValue.replace(/[^0-9$]/g, '');
// Format as currency with commas var formattedValue = inputValue.replace(/\D/g, '').replace(/\B(?=(\d{3})+(?!\d))/g, ',');
// Add the dollar sign formattedValue = "$" + formattedValue;
// Update the input value $(this).val(formattedValue); }); });