Skip to main content
Oct 16, 2025 3:20 PM UTC
Answered

Separate sentence into different text boxes

Hello,

 

I am looking for a script that will allow me to separate my "Year, Make, Model" textbox:

 

Text1 reads: 2019 Toyota Highlander

 

I need the following:

Text2: 2019

Text3: Toyota

Text4: Highlander

 

If I encounter a two-word name (like Land Rover or Mercedes-Benz), will I have to deal with it and leave it as one word (like LandRover, MercedesBenz)?

try67
try67Correct answer
Community Expert
Oct 16, 2025 9:55 PM UTC

Yes, unless you can define the logic to separate the make from the model (which can both be more than one word, so it's tricky to do, I think). But Mercedes-Benz will work fine, since it will be considered one word anyway.

The basic code would be something like this (as the custom Validation script of that field):

 

var parts = event.value.split(" ");
if (parts.length==3) {
	this.getField("Text2").value = parts[0];
	this.getField("Text3").value = parts[1];
	this.getField("Text4").value = parts[2];
} else {
	this.getField("Text2").value = "";
	this.getField("Text3").value = "";
	this.getField("Text4").value = "";
}

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Oct 16, 2025 9:55 PM UTC

Yes, unless you can define the logic to separate the make from the model (which can both be more than one word, so it's tricky to do, I think). But Mercedes-Benz will work fine, since it will be considered one word anyway.

The basic code would be something like this (as the custom Validation script of that field):

 

var parts = event.value.split(" ");
if (parts.length==3) {
	this.getField("Text2").value = parts[0];
	this.getField("Text3").value = parts[1];
	this.getField("Text4").value = parts[2];
} else {
	this.getField("Text2").value = "";
	this.getField("Text3").value = "";
	this.getField("Text4").value = "";
}
Translate