Text-type (e.g. "short free text", "huge free text") UpperCase + onBlur Trim

More
2 years 9 months ago #117763 by kmanapp
kmanapp created the topic: Text-type (e.g. "short free text", "huge free text") UpperCa
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.

Please Log in to join the conversation.

More
2 years 9 months ago #117799 by kmanapp
kmanapp replied the topic: Text-type (e.g. "short free text", "huge free text") UpperCa
I solved!

Below is the code for your reference:

<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

Please Log in to join the conversation.

More
2 years 9 months ago #117800 by kmanapp
kmanapp replied the topic: Text-type (e.g. "short free text", "huge free text") UpperCa
Below is the code for your reference:
<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>

Please Log in to join the conversation.

More
2 years 9 months ago #117801 by kmanapp
kmanapp replied the topic: Text-type (e.g. "short free text", "huge free text") UpperCa
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

Please Log in to join the conversation.

More
2 years 9 months ago #117807 by DenisChenu
DenisChenu replied the topic: Text-type (e.g. "short free text", "huge free text") UpperCa

kmanapp 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

Thanks for the tip, if you can put in in our manual please : manual.limesurvey.org/Workarounds:_Manip...ime_using_Javascript

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 (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
2 years 9 months ago - 2 years 9 months ago #117825 by kmanapp
kmanapp replied the topic: Text-type (e.g. "short free text", "huge free text") UpperCa
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
Last Edit: 2 years 9 months ago by kmanapp. Reason: Update the URL
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

More
2 years 9 months ago #117826 by DenisChenu
DenisChenu replied the topic: Text-type (e.g. "short free text", "huge free text") UpperCa

kmanapp 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

I think you don't save ;) manual.limesurvey.org/index.php?title=Wo...cript&action=history

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
2 years 9 months ago #117827 by kmanapp
kmanapp replied the topic: Text-type (e.g. "short free text", "huge free text") UpperCa
Sorry, now I clicked "save pages". Kindly please check :)
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

More
2 years 9 months ago #117869 by kmanapp
kmanapp replied the topic: Text-type (e.g. "short free text", "huge free text") UpperCa
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:
<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:
<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

Please Log in to join the conversation.

More
2 years 9 months ago #117914 by DenisChenu
DenisChenu replied the topic: Text-type (e.g. "short free text", "huge free text") UpperCa
Another solution for all text inside a question:
$(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 (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!