Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Force all caps

  • jimdavies
  • jimdavies's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 3 weeks ago #182326 by jimdavies
Force all caps was created by jimdavies
Is it possible to create a short answer question that forces the user to use all caps?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 weeks ago #182338 by tpartner
Replied by tpartner on topic Force all caps
LimeSurvey version?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • jimdavies
  • jimdavies's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 3 weeks ago #182373 by jimdavies
Replied by jimdavies on topic Force all caps
Version 2.58.0+170104
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 weeks ago #182375 by tpartner
Replied by tpartner on topic Force all caps
Place this script in the question source to force all uppercase in the text input:

Code:
<script type="text/javascript" charset="utf-8">
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Identify this question
    var thisQuestion = $('#question{QID}');
 
    // Listener on the text input
    $('input:text', thisQuestion).on('keyup', function(e) {
      $(this).val($(this).val().toUpperCase());
      checkconditions($(this).attr('value'), $(this).attr('name'), $(this).attr('type'));
    });
  });
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...27-2.lss
File Size:12 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • jimdavies
  • jimdavies's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 3 weeks ago #182376 by jimdavies
Replied by jimdavies on topic Force all caps
Thanks, the addition to the question source worked
<script type="text/javascript" charset="utf-8">

$(document).on('ready pjax:scriptcomplete',function(){

// Identify this question
var thisQuestion = $('#question{QID}');

// Listener on the text input
$('input:text', thisQuestion).on('keyup', function(e) {
$(this).val($(this).val().toUpperCase());
checkconditions($(this).attr('value'), $(this).attr('name'), $(this).attr('type'))
});
});
</script>
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose