Closed jonalxh closed 5 years ago
You could use the option parseWithFunction
and define your own function to trim spaces. For example:
const trimSpaces = (val, inputName) => {
if (typeof(val.trim) === 'function') { // check if is a string with the trim() method
return val.trim();
}
return val;
}
$('form').serializeJSON({parseWithFunction: trimSpaces});
Thanks a lot, I'm glad there is a method of doing it. I'll try later.
It worked perfectly, thanks again. :+1:
Hi, I wanna know if there is a way to remove extra spaces in the serialized strings, something like trim() which removes spaces of the beginning and the end.
It is just for not to have the need to iterate the json result again.
Thanks.