detect token lenght character in a question code

More
3 years 11 months 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
3 years 11 months ago - 3 years 11 months 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: 3 years 11 months ago by tpartner.

Please Log in to join the conversation.

Did you already participate in our customer survey?

Don't miss your chance for great prices.

Please click here to participate:

Start now

Start now!

Just create your account and start using Limesurvey today.

Register now