Using Javascript to replace text on #tokenmessage

More
3 years 1 month ago #122647 by stemate1988
stemate1988 created the topic: Using Javascript to replace text on #tokenmessage
Morning,

I have a bit of jquery which i want to use to replace some text in the #tokenmessage.
I want 'Please contact' to be replaced.

$("#tokenmessage p").text($("#tokenmessage p").text().replace("Please contact", "It looks as though you’ve recently completed the survey and provided your feedback. Unfortunately, we’re only able to accept one survey per applicant"));

Is this possible and where would the code have to sit?

Please Log in or Create an account to join the conversation.

More
3 years 1 month ago #122650 by tpartner
tpartner replied the topic: Using Javascript to replace text on #tokenmessage
It would probably be easier to replace the whole token message. Something like this at the end of template.js:

$(document).ready(function() {		
 
	// Define the new message
	var newMessage = 'We are sorry but you are not allowed to enter this survey.<br><br>\
						This invitation has already been used.<br><br>\
						It looks as though you’ve recently completed the survey and provided your feedback. Unfortunately, we’re only able to accept one survey per applicant.';
 
	// Insert the new message (only if the token form is missing)
	if($('#tokenmessage').length > 0 && $('#tokenform').length == 0) {
		$('#tokenmessage').html(newMessage);
	}
 
});

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
3 years 1 month ago #122653 by stemate1988
stemate1988 replied the topic: Using Javascript to replace text on #tokenmessage
That's spot on tpartner, thanks for your help!

Please Log in or Create an account to join the conversation.

More
3 years 1 month ago #122673 by DenisChenu
DenisChenu replied the topic: Using Javascript to replace text on #tokenmessage

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 or Create an account to join the conversation.

More
3 months 4 hours ago #168791 by MSMSEVN
MSMSEVN replied the topic: Using Javascript to replace text on #tokenmessage
Sorry I faced problem when I were using JavaScript to replace text on #token message.
I changed the token text and token label, but I can't change the warning message in case of invalid token.
I attached the script that I've been using in my survey.
Help me,please!
Thank you so much.
Attachments:

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!