Welcome to the LimeSurvey Community Forum

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

Using Javascript to replace text on #tokenmessage

More
11 years 2 months ago #122647 by stemate1988
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?
The topic has been locked.
More
11 years 2 months ago #122650 by tpartner
It would probably be easier to replace the whole token message. Something like this at the end of template.js:

Code:
$(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.
The topic has been locked.
More
11 years 2 months ago #122653 by stemate1988
That's spot on tpartner, thanks for your help!
The topic has been locked.
More
11 years 2 months ago #122673 by DenisChenu

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
8 years 4 months ago #168791 by MSMSEVN
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.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose