Skip to main content
Known Participant
August 21, 2025
Answered

Truncate test after character

  • August 21, 2025
  • 1 reply
  • 239 views

I have two text fields - Text1 and Text2.  In Text1, the user will type the name of a vendor followed by a dash followed by a description.  For example, the user might type XYX Corp - widgets.  The text in Text1 should then copy into Text2, but the text should be truncated in Text2 to only show the text before the dash.  In other words, Text2 would only contain XYZ, Corp.  Thanks.

Correct answer Nesa Nurani

As validate script of 'Text1' field use this:

var t2 = this.getField("Text2");
if (event.value){
 var str = event.value.split("-");
 t2.value = str[0].trim();}
else
 t2.value = "";

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
August 21, 2025

As validate script of 'Text1' field use this:

var t2 = this.getField("Text2");
if (event.value){
 var str = event.value.split("-");
 t2.value = str[0].trim();}
else
 t2.value = "";
Known Participant
August 21, 2025

It didn't work when I put it in validation script, but it did work when I put it in custom calculation script.  Thanks.