Welcome to the LimeSurvey Community Forum

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

Using Javascript to replace text on #tokenmessage

  • stemate1988
  • stemate1988's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
8 years 8 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.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 8 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 &amp;&amp; $('#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.
  • stemate1988
  • stemate1988's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
8 years 8 months ago #122653 by stemate1988
Replied by stemate1988 on topic Using Javascript to replace text on #tokenmessage
That's spot on tpartner, thanks for your help!
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 8 months ago #122673 by DenisChenu
Replied by DenisChenu on 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 , plugin development .
I don't answer to private message.
The topic has been locked.
More
5 years 10 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.
Attachments:
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose