Here is what I have try but not seem to work. Below are the two different script I have test.
1.
var result = “”;
add(record.fields[“MailingZip”], function (value) { result += value; });
result = result.replace(/[^0-9-]/, “”);
if (/^\d{6}$/.test(result)) {
result = result.substring(0,5) + “-” + result.substring(5);
}
results.html(result);
2.
{
function
add(value, operation) {
if
(value ===
undefined
|| value === ``""``)
return
;
operation(value);
}
var
result = ``""``;
add(record.fields[``"MailingZip"``],
function
(value) { result += value; });
result=``"0"``+result.slice(0,5)+``"-"``+result.slice(5,10);
results.html(result);
}