When I post text from HTML <form>  I get no following spaces so if I post text string who sould be 80 bytes long and the text is only 10 bytes i ONLY GET 10 BYTES LONG STRING.  How disable stripping off the spaces ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dr. KlahnPrincipal Software EngineerCommented:
What server is being used - Apache, IIS, nginx?
soffcecManagerAuthor Commented:
Windows 2012 IIS
Julian HansenCommented:
As far as I know you can't with the default form functionality  - HTML ignores white space. You will need to pad the string on the server.

However, you should be able to do it with jQuery
  <form action="t2322.php" method="post">
    <input type="text" name="comment" />
    <input type="submit" />
  <pre id="result"></pre>

Open in new window

<script src=""></script>
$(function() {
  $('form').submit(function(e) {
    var x = $(this).serialize();
    $.post('t2322.php', x, function(resp) {

Open in new window

Server script (for interest) - this just reflects the input with [ ] around the data to show the spaces.
echo "[{$_POST['comment']}]";

Open in new window

Working sample here
Ensure Business Longevity with As-A-Service

Using the as-a-service approach for your business model allows you to grow your revenue stream with new practice areas, without forcing you to part ways with existing clients just because they don’t fit the mold of your new service offerings.

Julian HansenCommented:
NB if the jQuery solution does not work for you then I would guess that whatever you are using server side is trimming the input in which case you must pad on the server or terminate the string on the client with a non-whitespace character which you then trim on the server.
Dave BaldwinFixer of ProblemsCommented:
Using the simplest possible <form> and text <input>, trailing spaces (in Firefox and Chrome) are sent as '+' signs and are normally converted back to spaces by the server.
Julian HansenCommented:
Updated sample following Dave's comment
<form action="t2322.php" method="post">
<input type="text" name="comment" />
<input type="submit">

Open in new window

$raw = file_get_contents("php://input");
echo "Raw : [{$raw}]<br/>";
echo "POST: [{$_POST['comment']}]<br/>";

Open in new window

Raw : [comment=abc++++++++++]
POST: [abc          ]

Open in new window

Sample here

I did an initial test to see if I could replicate the authors situation. When I looked at the results it appeared that I had - however, here was my mistake which I think is relevant to this discussion.

I viewed the results as HTML - which means even though the spaces where being sent to the server and reflected back to the browser - the HTML rendering of those results is what "removed" the white space from the submitted value - so the 10 spaces I added to the end of my input came out as a single space when rendered in HTML - an assumption on my part that what I was seeing was a trimmed response was in fact my just not seeing the single space at the end of the output.

This could have been prevented had I used <pre> tags as above to contain the output.

This might be what the author is seeing - the reflected value has the spaces but they are not being shown because of HTML rendering removing the superfluous white space.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.