Link to home
Start Free TrialLog in
Avatar of roscoeh23
roscoeh23

asked on

whitespace in textarea

when I create a form it automatically inserts some whitespace, about 7 or 8 characters worth in the box,.

When I insert the $_POST data and trim it this solves the problem but how can I delete the space when the page is opened for the first time?


Ross
ASKER CERTIFIED SOLUTION
Avatar of Eternal_Student
Eternal_Student
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CivilDisobedient
CivilDisobedient

Either attach an event to the window.onload, or if you're not doing any other onload routines, put the following in your page:

<script type="text/javascript">
   document.getElementById('textAreaId').innerHTML = "";
</script>

<body>
   <textarea id="textAreaId"></textarea>
</body>

Alternatively, you could do this to *every* textarea onload with the following script substitution:

<script type="text/javascript">
   var elems = document.getElementsByTagName('textarea');
   for (var x=0, i=elems.length; x < i; x++) {
      elems[x].innerHTML = "";
   }
</script>
Forgot to wrap that function in the window onload handler:

<script type="text/javascript">
   window.onload = function() {

   ...code goes here...

   }
</script>
hi
when u create ur form , check that all ur text ares are without spaces inside. If not, it wont be added when the page is opend