- Posts: 118
- Thank you received: 20
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
prevent CR/LF in text input
- orvil
- Topic Author
- Offline
- Premium Member
Less
More
9 years 3 months ago - 9 years 3 months ago #115276
by orvil
Best regards/Beste Grüße,
O. Villani
prevent CR/LF in text input was created by orvil
Hi there,
I'd like to prevent the input of a carriage return/line feed and may be some other characters like "§", "$" and "&" within free text answers. Especially CR/LF is a nuisance exporting the survey results into a csv file.
Any ideas for solutions?
THX in advance!
I'd like to prevent the input of a carriage return/line feed and may be some other characters like "§", "$" and "&" within free text answers. Especially CR/LF is a nuisance exporting the survey results into a csv file.
Any ideas for solutions?
THX in advance!
Best regards/Beste Grüße,
O. Villani
Last edit: 9 years 3 months ago by orvil.
The topic has been locked.
- c_schmitz
- Offline
- LimeSurvey GmbH Employee
Less
More
- Posts: 329
- Thank you received: 89
9 years 3 months ago #115277
by c_schmitz
Best regards
Carsten Schmitz
LimeSurvey project leader
Replied by c_schmitz on topic prevent CR/LF in text input
Hi Orvil,
Can you explain why it is a problem, what software do you use to parse it? It is a regular CSV format.
Can you explain why it is a problem, what software do you use to parse it? It is a regular CSV format.
Best regards
Carsten Schmitz
LimeSurvey project leader
The topic has been locked.
- orvil
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 118
- Thank you received: 20
9 years 3 months ago #115279
by orvil
Best regards/Beste Grüße,
O. Villani
Replied by orvil on topic prevent CR/LF in text input
Hi,
I have to import the csv into excel. The problem is, that the linefeeds are always starting a new row in excel, even if the single cell data and the CRLF is within quotation marks.
So eg a csv dataline like "1234","This is text with CRLF exactly here","42" (where the CR/LF where its written in the text) will lead to a table with 2 lines:
Additionally: I want to prevent respondents to edit some other characters like said before. Only a-z,A-Z,0-9, space, minus, plus, colon, comma and semicolon and may be a few other characters should be editable from the beginning on.
By the way: Validation would be another method, but its only my third choice due to survey usability.
I have to import the csv into excel. The problem is, that the linefeeds are always starting a new row in excel, even if the single cell data and the CRLF is within quotation marks.
So eg a csv dataline like "1234","This is text with CRLF exactly here","42" (where the CR/LF where its written in the text) will lead to a table with 2 lines:
1235 | This is text with |
exactly here | 42 |
Additionally: I want to prevent respondents to edit some other characters like said before. Only a-z,A-Z,0-9, space, minus, plus, colon, comma and semicolon and may be a few other characters should be editable from the beginning on.
By the way: Validation would be another method, but its only my third choice due to survey usability.
Best regards/Beste Grüße,
O. Villani
The topic has been locked.
- orvil
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 118
- Thank you received: 20
9 years 3 months ago #115286
by orvil
Best regards/Beste Grüße,
O. Villani
Replied by orvil on topic prevent CR/LF in text input
Hmm,
found a first solution by using JS/jQuery. Looks like this:
Has to be placed within the question text field as usual.
@Carsten Schmitz:
I'm wondering if it would'nt be very usefull to have an on field for JS code in the backend (in addition to the question-text and help-text fields)
There are some advantages for this:
1. clean and separated code / question text
2. code can be always visible to the editor (not only in sourcecode mode)
3. security and rights: eventually only dedicated persons can be allowed to see/edit js code
Any ideas for a better solution than mine above? (the disadvantage of this solution is: canceled keys are canceled for the whole question page or all questions if more than one is visible at the same time)
Any comments to the idea of an extra js-code field for the backend?
THX
found a first solution by using JS/jQuery. Looks like this:
Code:
<script type="text/javascript"> jQuery(document).ready(function() { jQuery(document).bind('keypress', function(e){ if (e.which == 13) return false; // kills enter-key event, can be replaced by any key code }) }); </script>
Has to be placed within the question text field as usual.
@Carsten Schmitz:
I'm wondering if it would'nt be very usefull to have an on field for JS code in the backend (in addition to the question-text and help-text fields)
There are some advantages for this:
1. clean and separated code / question text
2. code can be always visible to the editor (not only in sourcecode mode)
3. security and rights: eventually only dedicated persons can be allowed to see/edit js code
Any ideas for a better solution than mine above? (the disadvantage of this solution is: canceled keys are canceled for the whole question page or all questions if more than one is visible at the same time)
Any comments to the idea of an extra js-code field for the backend?
THX
Best regards/Beste Grüße,
O. Villani
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
9 years 3 months ago #115296
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic prevent CR/LF in text input
Try this:...the disadvantage of this solution is: canceled keys are canceled for the whole question page or all questions if more than one is visible at the same time...
Code:
<script type="text/javascript"> jQuery(document).ready(function() { jQuery('#question{QID} textarea').bind('keypress', function(e){ if (e.which == 13) return false; // kills enter-key event, can be replaced by any key code }) }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
9 years 3 months ago #115299
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic prevent CR/LF in text input
Hi,
With ast version, cr/lf on text question type show mutiline cell in excel. If not, you can make a bug report .
Denis
With ast version, cr/lf on text question type show mutiline cell in excel. If not, you can make a bug report .
Denis
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
9 years 3 months ago #115334
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic prevent CR/LF in text input
That is probably not a bug or Limesurvey issue but stupid Excel not being able to deal with CSV files properly.
MS Excel doesn't even stick to CSV standard and is famous for breaking CSV files on save.
MS Excel doesn't even stick to CSV standard and is famous for breaking CSV files on save.
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.