SELECTED ANSWER
replied on September 10, 2024
//Commas and Other Value length
const fields = LFForm.findFields(f =>
(f.componentType == "Checkbox" || f.componentType == "Radio") ||
(f.componentType == "SingleLine" || f.componentType == "MultiLine"))
;
fields.forEach(f => {
let fld = LFForm.findFieldsByFieldId(f.fieldId)[0];
if (f.componentType == "SingleLine" || f.componentType == "MultiLine") {
LFForm.onFieldChange(() => { RemoveCommas(f.fieldId); }, fld);
}
else {
LFForm.onFieldChange(() => { ValidateOtherField(f.fieldId); }, fld);
}
});
function RemoveCommas(fldId){
console.log(fldId);
let fld = LFForm.findFieldsByFieldId(fldId)[0];
let fldValue = LFForm.getFieldValues({fieldId: fldId});
if (fldValue.indexOf(',') > 0){
let newVal = fldValue.replaceAll(',','');
LFForm.setFieldValues(fld, newVal);
LFForm.changeFieldSettings(fld, {
"subtext": "<b>Note:</b> Comma(s) have been removed."
});
}
}
Use this JS with the css class .otherchoice in the fields you don't want commas allowed.