I think trim()
doesn't store the trimmed value.
I apply trim to the result before the user submits their string and it works, it displays properly by removing the extra space. But if I retrieve the trimmed value back, it gives me the original of user's input, it doesn't remove space.
Before I retrieve the user input from the input field, I added trim()
:
input = $("<input type='text'>").val(txt);
input.trim()
It doesn't work.