- Posts: 55
- Thank you received: 1
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Assign column-specific classes $('tr.subquestion-list', thisQuestion).each(function(i) { $('th, td', this).each(function(i) { $(this).addClass('column-'+i); }); }); // First column $('.answer-item.column-1 input:text', thisQuestion).attr('size', 200); // Second column $('.answer-item.column-2 input:text', thisQuestion).attr('size', 4); // Listener on column 2 inputs $('.answer-item.column-2 input:text', thisQuestion).on('keyup change', function(e) { var thisValue = $.trim($(this).val()); // Strip out non-numerics characters newValue = thisValue.replace(/\D/g,'').replace(/,/g,'').replace(/\./g,''); $(this).val(newValue).trigger('change'); }); }); </script>
// Second column $('.answer-item.column-2 input:text', thisQuestion).attr('maxlength', 3);
$('.answer-item.column-1 input:text', thisQuestion).attr('size', 200);