Numbers ought to be automatically separated by commas.

karz insurance
Mega Explorer

Hi everyone, I have designed a Typeform that requests project budgets from users to provide a price based on that information. The generated and budget input areas could have a sizable number of digits. It can be highly perplexing to look at these numbers without commas (especially if there is a succession of 0s0s).

 

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

Hi @ karz insurance 

sorry, I don't get your point. Please provide more information and screenshot to help us understand you better.

Maik

BalaG
Kilo Sage

Hello @ karz insurance   you need a onChange client script that rewrites the number with commas. Here is an example  that works on my PDI

 

var isScriptChange = false;
function addCommas(number) {
	var parts = number.toString().split(".");
	parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
	return parts.join(".");
}
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {
		return;
	}
	if (isScriptChange) {
        isScriptChange = false;          // Reset the flag and exit
        return;
    }
	isScriptChange = true;
	g_form.setValue( 'u_long_number', addCommas(newValue));  // REPLACE field name with the actual field
}

 

Hope this helps

--

Bala Guthy

 

Please mark this as a solution or helpful as appropriate