Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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 ");
Copy link to clipboard
Copied
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");
}
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
No, nothing else is needed. Did you remove the Format script?
And being on a Mac shouldn't matter.
Copy link to clipboard
Copied
I've removed all other scripts. Should I add it back in? Thanks again
Copy link to clipboard
Copied
No. Be aware this will only work when you exit the field, though, not while you're typing into it.
Copy link to clipboard
Copied
Is there a way to make it appear when you're typing into it? or would it be best to paste the unicode in as the default answer to start?
Copy link to clipboard
Copied
To avoid empty lines from having a bullet added to them, use this:
if (event.value != "") {
event.value = event.value.split(/\r|\n/).map(function(a){if (a!="") return "\u2022 " + a.replace("\u2022 ", "")}).join("\n");
}
Attached is a working example.
Copy link to clipboard
Copied
Sadly, neither code is working for me... I'm not sure why
Copy link to clipboard
Copied
Does the file I attached work for you?
Copy link to clipboard
Copied
Yes, that form works. I think I've made it work based on another script you wrote on another post:
I set the keystroke script to:
if (event.change=="\n") event.change+="\u2022\t";
and I created an On Focus trigger:
if (event.target.value=="") event.target.value="\u2022\t";
Copy link to clipboard
Copied
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 ");
Copy link to clipboard
Copied
I'll try this too. Thanks so much Nesa!

