You need to add a trim function to the form's JavaScript section first and then use the simple syntax as you want:
$(LastName) = trim($(LastName));
>>Advanced Field Options
>>Client side event
>>Put the above Javascript in the box for each Field.
Case sensetive so use "trim" instead of "Trim"!
You can put either trim function below to the Javascript section:
>>Setup Module Configuration
>>Advanced Coding Options (AJAX, jQuery, JavaScript, Initial SQL DataBind)
>> Custom JavaScript File
>> JavaScript File
(Add the trim function within this section and click on Update Javascript File
and then click on Update Settings
function trim(stringToTrim) {
return stringToTrim.replace(/^\s+|\s+$/g,"");
}
/*
http://www.somacon.com/p355.php
*/
Or this one:
function trim(s)
{
var l=0; var r=s.length -1;
while(l < s.length && s[l] == ' ')
{ l++; }
while(r > l && s[r] == ' ')
{ r-=1; }
return s.substring(l, r+1);
}
/*
http://doc.infosnel.nl/javascript_trim.html
*/