Welcome, Guest
Username: Password: Remember me

TOPIC: Display commas in long numeric inputs

Re: Display commas in long numeric inputs 2 years 11 months ago #68478

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4269
  • Thank you received: 803
  • Karma: 368
Hmm...I'm not sure what is going on - I've never run across that problem and the workaround demo is recording correct values using this mask and the separator set to"." as your's is:
customMask2:{mask: '99.999,9', type : 'reverse', defaultValue : '000'}

However, here is a workaround for the workaround - add a function to remove the commas before the page submits.

Add the following script to the end of template.js. It will interrupt the Next/Submit function and remove all commas from numeric and multi-numeric inputs.
 
	$(document).ready(function() {
 
		// Interrupt next/submit function 
		$('#movenextbtn, #movesubmitbtn').click(function(){
 
			$('.numeric input.text, .numeric-multi input.text').each(function(){
				$(this).val($(this).val().replace(/,/g,''));
			});
 
			return true;
		});
 
	});
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 2 years 11 months ago by tpartner.
The administrator has disabled public write access.

Re: Display commas in long numeric inputs 2 years 11 months ago #68605

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5331
  • Thank you received: 296
  • Karma: 249
Does the above solution solve your problem?

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Display commas in long numeric inputs 2 years 11 months ago #68624

  • Fred
  • Fred's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 163
  • Thank you received: 5
  • Karma: 3
Hi Mazi and Tony. I came in yesterday and spent some more time on this. Unfortunately it still didn't work. I appreciate all your ideas though!!

I thought it might be my template or my survey, so I made a copy of the default template, imported the Sample LimeSurvey Survey for v1.9, and then set up the mask on the first numeric question (first question in the second group.)

Mask: customMaskThousands:{mask: '.999,999,999,9', type : 'reverse'} // I didn't want a default value so I removed.

Decimal separator: Dot (.)

Here is how it handles different numeric inputs:

Enter -> Displays -> Stores in Database
9 -> 9. -> 9
99 -> 99. -> 99
999 -> 999. -> 999
9999 -> 9,999. -> 9.999
99999 -> 99,999. -> 99.999
999999 -> 999,999 -> 999.999
9999999 -> 9,999,999 -> 9.999

It doesn't seem to make any difference whether the additional workaround script is included in template.js.

Note, I am a javascript novice so if it's beyond cutting and pasting then I need to go read a js book. I wonder if input masks are the sort of thing the new Expression Manager will help out with. Interestingly, I notice Survey Monkey seems to have the same problem with large numbers.

Maybe there is something about my setup that is interfering.

Fred
The administrator has disabled public write access.

Re: Display commas in long numeric inputs 2 years 11 months ago #68638

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4269
  • Thank you received: 803
  • Karma: 368
Did you add my fix to remove the commas?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Display commas in long numeric inputs 2 years 11 months ago #68654

  • Fred
  • Fred's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 163
  • Thank you received: 5
  • Karma: 3
Yes, I put the comma-removing script in the template.js

One interesting thing on the LS Sample Survey using the default template: It does seem to take the commas out and save the number correctly when you press Next and go to the next screen, and the data in the database is correct. But if you save it, then use the previous button to go back a page, then next to go forward to the original page, it truncates it and you end up with only the first few digits. Maybe that's because the interrupt is only doing #movenextbtn, #movesubmitbtn? Should I add the previous and resume later buttons to it?

Fred
The administrator has disabled public write access.

Re: Display commas in long numeric inputs 2 years 11 months ago #68656

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4269
  • Thank you received: 803
  • Karma: 368
Yeah, you could definitely try that.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Display commas in long numeric inputs 2 years 11 months ago #68659

  • Fred
  • Fred's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 163
  • Thank you received: 5
  • Karma: 3
Ok I'll try it out.
The administrator has disabled public write access.

Re: Display commas in long numeric inputs 2 years 11 months ago #68664

  • Fred
  • Fred's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 163
  • Thank you received: 5
  • Karma: 3
I think I have the main problem isolated to my template.

If I use the default template and include Tony's javascript to remove the commas then it is saving the numbers correctly (although you can still mess it up by using "previous" button.

If I use my own template (an edited copy of the sherpa template) then it doesn't work. The template.js files are identical between the two templates. Other than the .css I don't think I made many changes to the other files in the sherpa template.

Any other ideas? Sorry for the continuing trouble.
The administrator has disabled public write access.

Re: Display commas in long numeric inputs 2 years 11 months ago #68666

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4269
  • Thank you received: 803
  • Karma: 368
Fred, if you can zip up and attach your template, I'll try it.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Display commas in long numeric inputs 2 years 11 months ago #68669

  • Fred
  • Fred's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 163
  • Thank you received: 5
  • Karma: 3
HI Tony, Gladly. File is attached. I just remembered that this one is based on the Mint_idea template (not sherpa as I thought). The unedited Mint_idea is working correctly, so I messed up something in this one.
Attachments:
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.126 seconds
Donation Image