Change dot to comma with Client Script

Jonatan4
Giga Guru

I'm trying to change a dot to a comma but a cannot get it to work.

Any ideas?

I'm not sure if I need the parseFloat, doesn't make a different though. 

Also, setValue in the end tries to go multiple times... 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {
		return;
	}

	var fte = g_form.getValue('fte');

	if(fte.indexOf('.')){
		parseFloat(fte);
		fte.replace(/./g, ',');
		
 		g_form.setValue('fte', fte);
	}
	
}
1 ACCEPTED SOLUTION

Munender Singh
Mega Sage

Hi,

Use this piece of code:

var fte = g_form.getValue('fte').toString();

if(fte.indexOf('.')>-1){

fte.replace('.', ',');

g_form.setValue('fte', fte);

 

 

Regards,

Munender

View solution in original post

2 REPLIES 2

Munender Singh
Mega Sage

Hi,

Use this piece of code:

var fte = g_form.getValue('fte').toString();

if(fte.indexOf('.')>-1){

fte.replace('.', ',');

g_form.setValue('fte', fte);

 

 

Regards,

Munender

AbhishekGardade
Giga Sage

Hello Jonatan,

Replace your code with this;

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

var originalText = g_form.getValue('fte');

var formattedText;

if(originalText.indexOf('.')){

  
     formattedText  = originalText.replace(".", ",");

     g_form.setValue('fte', formattedText);
}

}

Thanks,
Abhishek

Thank you,
Abhishek Gardade