Page 1 of 1

[solved] Textarea problem

Posted: Fri Feb 13, 2004 7:25 am
by melindaSA
I have a textarea and when the user enters info into the textarea, they can click anywhere in the box, how do I force the curser to the left. Also when the form is submitted, if there is no info entered into the box, it is submitted with spaces, so mySql shows that it is not null. I have tried stripslashes and trim......Help!!

Here is my code:

Code: Select all

<tr>
    <td>Required:</td>
    <td><textarea rows="5" cols="30"
          name="r_experience">
          <?php echo trim($edit?$positions&#1111;'r_experience']:''); ?>
          </textarea></td>

 </tr>
  <tr>
    <td>Preferred:</td>
    <td><textarea name="p_experience" rows="5" cols="30" wrap="physical">
          <?php echo $edit?$positions&#1111;'p_experience']:''; ?>
          </textarea></td>
  </tr>
?>

Posted: Fri Feb 13, 2004 8:08 am
by markl999
Just let them type whatever they want in the textarea, spaces/nothing etc.. and trim() the posted var then check if it's empty() or not. E.g.

if(isset($_POST['r_experience'])){
$r_exp = trim($_POST['r_experience']);
if(!empty($r_exp)){
//it's been trimmed and it's not empty, can go in db
} else {
//it's empty so ignore inserting it
}
}

Posted: Fri Feb 13, 2004 8:24 am
by jason
Try

Code: Select all

<tr>
    <td>Required:</td>
    <td><textarea rows="5" cols="30"
          name="r_experience"><?php echo trim($edit?$positions&#1111;'r_experience']:''); ?></textarea></td>

</tr>
  <tr>
    <td>Preferred:</td>
    <td><textarea name="p_experience" rows="5" cols="30" wrap="physical"><?php echo $edit?$positions&#1111;'p_experience']:''; ?>          </textarea></td></tr>
You had spaces between your <textarea> tags, and that is what was causing the problem.

Posted: Mon Feb 16, 2004 10:57 am
by melindaSA
Thank you, that has fixed it.... :D