detect token lenght character in a question code

More
4 years 2 weeks ago #99720 by startx25
startx25 created the topic: detect token lenght character in a question code
Hi,

I don't know why but this code doesn't work

<script type="text/javascript">
var mytok;
if({TOKEN}.length < 4){
mytok1 = "smaltoken";
}else{
mytok2 = {TOKEN};
}

</script>

With javascript in a question code,
I am trying to identify some token who have ony 4 characters,
but this condition deosn't match...

thank you for any help

Please Log in to join the conversation.

More
4 years 2 weeks ago - 4 years 2 weeks ago #99754 by tpartner
tpartner replied the topic: detect token lenght character in a question code
Try something like this:
<script type="text/javascript">
	var mytok;
	var token = "{TOKEN:ATTRIBUTE_1}";
	if(token.length < 4){
		mytok1 = "smaltoken";
	}
	else{
		mytok2 = token;
	}
 
</script>

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 4 years 2 weeks ago by tpartner.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now