Skip to main content
Participating Frequently
December 11, 2023
Answered

Custom Format Script - Bullet Points in Text Field

  • December 11, 2023
  • 2 replies
  • 4024 views

Hi everyone,

I'm trying to make answers in a multi-line text field format into bullet points. I've used this script posted elsewhere on the forum that works:

if(event.value != "") {
event.value = event.value.split(/\r|\n/).map(function(a){return "\u2022 " + a}).join("\n");
}

However, I was wondering if there's a way for the user to see the bullet points when they type their answer, as they only appear after they click out of the text field.

Best

This topic has been closed for replies.
Correct answer Nesa Nurani

Use this as 'Custom keystroke script' under 'Format' tab:

if (event.value === "")
 event.change = "\u2022 ";
else
 event.change = event.change.replace(/\n/g, "\n\u2022 ");

2 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
December 11, 2023

Use this as 'Custom keystroke script' under 'Format' tab:

if (event.value === "")
 event.change = "\u2022 ";
else
 event.change = event.change.replace(/\n/g, "\n\u2022 ");
Participating Frequently
December 11, 2023

I'll try this too. Thanks so much Nesa!

try67
Community Expert
Community Expert
December 11, 2023

In order to do that you can't use the Format event, as that doesn't actually change the field's value.

You need to move your code to the Validation event, for example. But then there's a new issue: You will need to change it so that it doesn't add the bullet-points if they already exist at the start of a line, or you'll end up with a new bullet each time you edit the field.

One way to do that is the following:

 

if(event.value != "") {
	event.value = event.value.split(/\r|\n/).map(function(a){return "\u2022 " + a.replace("\u2022 ", "")}).join("\n");
}
Participating Frequently
December 11, 2023

Hi try67,

Thanks for responding and your help 🙂

I've tried adding that as a custom script in the Validation section, but it isn't doing anything. Do I need to use it in conjunction with anything else? I'm using a Mac if that helps.
Best

try67
Community Expert
Community Expert
December 11, 2023

No, nothing else is needed. Did you remove the Format script?

And being on a Mac shouldn't matter.