Prevent editing of text field

Más
1 mes 3 días antes #192650 por ch123
Hey. Again me with another question ;)
My survey has a short explanation text and on this basis first an open text field and then several single choice questions. Sometimes the single choice questions repeat a part of the open text question. That's why I want to prevent participants from editing their written text.
My ideas to do it:
1) Disable the previous button. Found this thread and it worked. But of course with it it's not possible to go back to other parts of the survey (as this text comprehension task is just a short part of the whole survey). So is it possible with this js-code to skip the page with the text field, but still go further back to the other parts?
2) Prevent editing the text field with grey out or something. So after validating the answer with pressing "next" it shouldn't be possible to do any changes...
Is it possible to do this?
Thanks in advance! :)

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

LimeSurvey Partners
Más
1 mes 3 días antes #192655 por Joffm
Respuesta de Joffm sobre el tema Prevent editing of text field
Hi,
my idea is - as usual only with built-in functions - to store the entered text in a hidden question of the same type.

1. There is the question "Open1"
2. create a hidden question of the same type "Open2"
Now create two hidden equations:
3. Store the value of "Open1" into "Open2", BUT ONLY if "Open2" is still empty.
Equation: {Open2=if(is_empty(Open2),Open1,Open2)}
4. Restore "Open2" into "Open1"
Equation: {Open1=Open2}
So, if "Open1" was changed, the "old" value is entered again.

Example. You will see, the first entered text doesn't change.

Archivo Adjunto:

Nombre del Archivo: limesurvey...7655.lss
Tamaño del Archivo:17 KB


Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Adjuntos:
El siguiente usuario dijo gracias: ch123

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 mes 3 días antes #192663 por tpartner
Respuesta de tpartner sobre el tema Prevent editing of text field
My solution, as usual, includes JavaScript. :)

On page load, if the text element is not empty, disable it.

For a long-text question, something like this in the question source:

<script type="text/javascript" charset="utf-8">
 
	$(document).on('ready pjax:scriptcomplete',function(){
 
		if($.trim($('#question{QID} textarea:eq(0)').val()) != '') {
			$('#question{QID} textarea:eq(0)').prop('readonly', true);
		}
    });
</script>

For a short-text question, something like this in the question source:

<script type="text/javascript" charset="utf-8">
 
	$(document).on('ready pjax:scriptcomplete',function(){
 
		if($.trim($('#question{QID} input:text:eq(0)').val()) != '') {
			$('#question{QID} input:text:eq(0)').prop('readonly', true);
		}
    });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
El siguiente usuario dijo gracias: ch123

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 mes 3 días antes #192666 por Joffm
Respuesta de Joffm sobre el tema Prevent editing of text field

My solution, as usual, includes JavaScript

:lol: :lol: :lol:

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Más
1 mes 2 días antes #192675 por ch123
Respuesta de ch123 sobre el tema Prevent editing of text field
Both solutions are awesome - thanks a lot, Joffm & tpartner!
Now I have to decide which one works better for me :D

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

¡Comenzar ahora!

Simplemente cree una cuenta y comience a usar LimeSurvey hoy mismo.

Registrarse ahora
¡Únase a nuestro boletín informativo!

Iniciar sesión