separate values in a string by commas if testbox is not empty
I would like to combine values from several textboxes into a single textbox with the values separated by commas. However, some of the textboxes may be empty so sometimes I get double commas next to each other or a value with a comma behind it but no additional value to follow. here is the start of my code.
// Get the field values, as strings
var s1 = getField("Text6").valueAsString;
var s2 = getField("Text12").valueAsString;
var s3 = getField("Text13").valueAsString;
var s4 =getField("Text14").valueAsString;
var s5 =getField("Text15").valueAsString;
//combine values with comma
event.value= s1 + "," + s2.......
Please help, thanks.
