Jump to content
Larry Ullman's Book Forums

When Reading Data Into A Text Field From A Db, Safari Does Not Ignore White Space


Recommended Posts

Here's the code to read in a date from a db. The date itself, from the db table, contains no white space:

 

Date Created: <input type="text" name="datecreated" size="12" maxlength="10" value="<?php echo $row['dateCreated'] ?>"  /> yyyy-mm-dd<br />

 

 

If I go into my code and hit the return button after  value="  it looks like this:

 

Date Created: <input type="text" name="datecreated" size="12" maxlength="10" value="

<?php echo $row['dateCreated'] ?>"  /> yyyy-mm-dd<br />

 

In Firefox, this has no effect a-as it should. However Safari will insert a space before the date value in the text field. This is a problem because the value for date within the form will not validate when it hits the space.

 

Even if I insert a trim() in the above line:

Date Created: <input type="text" name="datecreated" size="12" maxlength="10" value="<?php echo trim($row['dateCreated']) ?>"  /> yyyy-mm-dd<br />

 

it still inserts a space.

 

I've never considered the arbitrary code formatting practice of hitting a return anywhere I want. Has anyone else run into this?

 

 

Link to comment
Share on other sites

I don't really understand the point here. You said:

If I go into my code and hit the return button after value="

How about you don't do that? YOU are the one introducing the extra space within the value attribute. This isn't a user issue and it doesn't really matter what the different browsers do. Just don't do that. This is an entirely solvable and controllable problem.

Link to comment
Share on other sites

Sorry. It's not that I couldn't get it to work after taking out the returns in my code. I was just curious because I tend to enter returns in Dreamweaver code view to break lines into a more visually understandable format. I never knew it could cause a problem.

 

I will withdraw the question.

Link to comment
Share on other sites

 Share

×
×
  • Create New...