- Posts: 37
- Thank you received: 4
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Text-type (e.g. "short free text", "huge free text") UpperCase + onBlur Trim
- kmanapp
- Topic Author
- Offline
- Junior Member
Less
More
9 years 2 weeks ago #117763
by kmanapp
Text-type (e.g. "short free text", "huge free text") UpperCase and onBlur Trim was created by kmanapp
Dear friends,
I would like to seek your kindness help on how to enforce uppercase and onblur trim (whitespace) on a text type input (e.g. "short free text" or "huge free text")? Thanks.
I would like to seek your kindness help on how to enforce uppercase and onblur trim (whitespace) on a text type input (e.g. "short free text" or "huge free text")? Thanks.
The topic has been locked.
- kmanapp
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 37
- Thank you received: 4
9 years 2 weeks ago #117799
by kmanapp
Replied by kmanapp on topic Text-type (e.g. "short free text", "huge free text") UpperCase and onBlur Trim
I solved!
Below is the code for your reference:
Below is the code for your reference:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready( function() { var my_surveyId='{SID}'; var my_groupId='{self.gid}'; var my_quesitonId='{self.qid}'; var my_self='{self.sgqa}'; // Operate for its appearance only (but have no effect to modify its intrinsic value): Display as UpperCase $('#answer{self.sgqa}').css('text-transform', 'uppercase'); $('#answer{self.sgqa}').blur(function(){ // Operate for its intrinsic value: Trim + Transform to Uppercase $(this).val( $.trim( $(this).val().toUpperCase() ) ); }); }); </script>
The following user(s) said Thank You: DenisChenu
The topic has been locked.
- kmanapp
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 37
- Thank you received: 4
9 years 2 weeks ago #117800
by kmanapp
Replied by kmanapp on topic Text-type (e.g. "short free text", "huge free text") UpperCase + onBlur Trim
Below is the code for your reference:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready( function() { var my_surveyId='{SID}'; var my_groupId='{self.gid}'; var my_quesitonId='{self.qid}'; var my_self='{self.SGQA}'; // Operate for its appearance only (but have no effect to modify its intrinsic value): Display as UpperCase $('#answer{self.SGQA}').css('text-transform', 'uppercase'); $('#answer{self.SGQA}').blur(function(){ // Operate for its intrinsic value: Trim + Transform to Uppercase $(this).val( $.trim( $(this).val().toUpperCase() ) ); }); }); </script>
The topic has been locked.
- kmanapp
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 37
- Thank you received: 4
9 years 2 weeks ago #117801
by kmanapp
Replied by kmanapp on topic Text-type (e.g. "short free text", "huge free text") UpperCase and onBlur Trim
Just realise that I wrongly post this thread in "Instlalation & Update issues" forum, I have made a correct one in the "Can I do this with LimeSurvey" forum and has this URL:
www.limesurvey.org/en/forum/can-i-do-thi...ppercase-onblur-trim
www.limesurvey.org/en/forum/can-i-do-thi...ppercase-onblur-trim
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13907
- Thank you received: 2546
9 years 2 weeks ago #117807
by DenisChenu
And the last time : just ask to move, we do it in one click, here : i need 4
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 Text-type (e.g. "short free text", "huge free text") UpperCase and onBlur Trim
Thanks for the tip, if you can put in in our manual please : manual.limesurvey.org/Workarounds:_Manip...ime_using_Javascriptkmanapp wrote: Just realise that I wrongly post this thread in "Instlalation & Update issues" forum, I have made a correct one in the "Can I do this with LimeSurvey" forum and has this URL:
www.limesurvey.org/en/forum/can-i-do-thi...ppercase-onblur-trim
And the last time : just ask to move, we do it in one click, here : i need 4
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.
- kmanapp
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 37
- Thank you received: 4
9 years 2 weeks ago - 9 years 2 weeks ago #117825
by kmanapp
Replied by kmanapp on topic Text-type (e.g. "short free text", "huge free text") UpperCase and onBlur Trim
Great, briefly added here, kindly please feel free to revise:
Text Input (e.g. "short free text", "huge free text"): Force UpperCase + onBlur Trim
manual.limesurvey.org/Workarounds:_Manip...Case_.2B_onBlur_Trim
Text Input (e.g. "short free text", "huge free text"): Force UpperCase + onBlur Trim
manual.limesurvey.org/Workarounds:_Manip...Case_.2B_onBlur_Trim
Last edit: 9 years 2 weeks ago by kmanapp. Reason: Update the URL
The following user(s) said Thank You: DenisChenu
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13907
- Thank you received: 2546
9 years 2 weeks ago #117826
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 Text-type (e.g. "short free text", "huge free text") UpperCase and onBlur Trim
I think you don't save manual.limesurvey.org/index.php?title=Wo...cript&action=historykmanapp wrote: Great, briefly added here, kindly please feel free to revise:
Text Input (e.g. "short free text", "huge free text"): Force UpperCase + onBlur Trim
manual.limesurvey.org/index.php?title=Wo...Case_.2B_onBlur_Trim
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.
- kmanapp
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 37
- Thank you received: 4
9 years 2 weeks ago #117827
by kmanapp
Replied by kmanapp on topic Text-type (e.g. "short free text", "huge free text") UpperCase and onBlur Trim
Sorry, now I clicked "save pages". Kindly please check
The following user(s) said Thank You: DenisChenu
The topic has been locked.
- kmanapp
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 37
- Thank you received: 4
9 years 2 weeks ago #117869
by kmanapp
Replied by kmanapp on topic Text-type (e.g. "short free text", "huge free text") UpperCase and onBlur Trim
The above codes is generally for "text questions" (i.e., "short free text", "long free text", "huge free text").
For other textual-type questions, below are the relevant code illustrating "OnBlur Trim" purpose:
For "Multiple Choice" question enabled with the "Other" option:
For "List (radio)" question enabled with the "Other" option:
For other textual-type questions, below are the relevant code illustrating "OnBlur Trim" purpose:
For "Multiple Choice" question enabled with the "Other" option:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready( function() { var this_surveyId='{SID}'; var this_groupId='{self.gid}'; var this_quesitonId='{self.qid}'; var this_self='{self.sgqa}'; $('#answer{self.sgqa}').blur(function(){ $(this).val( $.trim( $(this).val() ) ); }); }); </script>
For "List (radio)" question enabled with the "Other" option:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready( function() { var this_surveyId='{SID}'; var this_groupId='{self.gid}'; var this_quesitonId='{self.qid}'; var this_self='{self.sgqa}text'; $('#answer{self.sgqa}text').blur(function(){ $(this).val( $.trim( $(this).val() ) ); }); }); </script>
The following user(s) said Thank You: Ben_V
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13907
- Thank you received: 2546
9 years 2 weeks ago #117914
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 Text-type (e.g. "short free text", "huge free text") UpperCase and onBlur Trim
Another solution for all text inside a question:
Code:
$(document).on('blur',"#question{QID} input:text,#question{QID} textarea",function(){ $(this).val( $.trim( $(this).val() ) ); });
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.