Crowley Astray Crowley Astray -4 years ago 63
HTML Question

How to stop HTML Form from 'skimping' Spaces

Basically, I have following problem:

I have a HTML Form with a textfield which has multiple spaces behind each other, yet when submitting the form, they are reduced to one space.

In the textfield, it would have this format:

.-- .-

But when reading it in, it has this format:

.-- .-

My problem is that when submitting the TextField, it matters whether there are one, two, three, or however many spaces behind each other.

How can I stop the TextField from automatically reducing the spaces to one?

I am using it in a JSP project, but I don't think that matters. Any help would be greatly appreaciated.

I found this related Question, however it has no accepted answer and the only answer given does not work for me.

Answer Source


You can use the white-space css property to accomplish this. Something like:

<textarea style="white-space: pre"></textarea >
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download