- Posts: 26
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
insert javascript code in a question with { and } in source
9 years 10 months ago #96080
by startx25
Hi,
I am trying to check a textarea during a keypress event. (looking for 5 consonnes)
i want to use regex to do that so :
.....
$("#answer21812X30X985").keypress(function(event) {
var reg = new RegExp("[bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ]{5,}", "g");
alert(reg.test($("#answer21812X30X985").val()));
}
but when i insert this code, limesuvey replace in generated source with this :
var reg = new RegExp("[bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ]<span style='background-color: #eee8aa;'><span title='Pas une expression valide; Expression mal terminée - attendait une constante ou variable' style='border-style: solid; border-width: 2px; border-color: red;'>5</span>, </span>", "g");
so how can i insert symbol { and } in source question ?
I am trying to check a textarea during a keypress event. (looking for 5 consonnes)
i want to use regex to do that so :
.....
$("#answer21812X30X985").keypress(function(event) {
var reg = new RegExp("[bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ]{5,}", "g");
alert(reg.test($("#answer21812X30X985").val()));
}
but when i insert this code, limesuvey replace in generated source with this :
var reg = new RegExp("[bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ]<span style='background-color: #eee8aa;'><span title='Pas une expression valide; Expression mal terminée - attendait une constante ou variable' style='border-style: solid; border-width: 2px; border-color: red;'>5</span>, </span>", "g");
so how can i insert symbol { and } in source question ?
The topic has been locked.
9 years 10 months ago #96093
by cshaw
Replied by cshaw on topic insert javascript code in a question with { and } in source
Do you have to wrap it with <script></scrip> tags?
The topic has been locked.
9 years 10 months ago #96099
by TMSWhite
If you depend upon LimeSurvey or the support team, please give generously to our 2012 fundraiser .
Replied by TMSWhite on topic insert javascript code in a question with { and } in source
Expression Manager processes anything between curly braces unless there is whitespace immediately after the opening curly brace and before the closing one. So, add that whitespace:
Code:
$("#answer21812X30X985").keypress(function(event) { var reg = new RegExp("[bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ]{ 5, }", "g"); alert(reg.test($("#answer21812X30X985").val())); }
If you depend upon LimeSurvey or the support team, please give generously to our 2012 fundraiser .
- Expression Manager (EM):
Documentation
|
Sample Surveys
|
How Tos
|
Show Logic File
|
Upgrading to 1.92+ - Excel Style for Survey Structure Import/Export
The topic has been locked.